We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multiple Select Title

so i have the following :

$form->add(new Select( "client" , Clients::find() ,
[
'using' =>  ['id','firstname'],
'data-placeholder' => "Membros Participantes",
'class'            => "chosen-select"
]
));

So how can i in the using method pass 2 texts ? Example: using=>[id,FIRSTNAME,LASTNAME]



11.6k
edited Apr '16

you can create a custom "findForSelect" function in your model, where you do the aggregate

    public static function findForSelect()
    {
      $users = parent::find(array(
                  "columns" => (
                  array(
                      "id",
                      "surname",
                      "name")
                  )
              ));
              $length = count($users);
              $unames = array();
              for($i=0;$i<$length;$i++) {
                  $unames[$users[$i]['id']] = $users[$i]['prenom'] . " " . $users[$i]['nom'];
              }

              return $unames;
          }

html

        <?php echo $this->tag->select(array(
                'useraggregate',
                Utilisateurs::findForSelect(),
                'using' => array('id', "nom"),
                'useEmpty' => false,
          ));?>

this work ..