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 Form Select Column Name

How can i add a firstnameand lastname in a Form select ?


$form->add(new Select( "client" , Clients::find() ,
[
'using'         =>  ['id','firstname'], # so i can select the firstname but i also want to add the lastname with the first
'data-placeholder' => "Members",
'class'            => "chosen-select"
]
));


12.2k
edited May '16

Like this:


      $form->add(new Select( "client" , Clients::find(
              [
                  'columns' => ['CONCAT(firstname, " ", lastname) as fullname', 'id']       # This is for MySQL database
              ]
        ) ,
          [
          'using'           =>  ['id','fullname'], 
          'data-placeholder' => "Members",
          'class'            => "chosen-select"
          ]
        )
      );