How to assign a name to dropdown options

Using the Phalcon framework, I have a Form class file in which I declare select

and render

in the .volt

file:

$soc_bulding =  new Select("soc_building_id", $options['soc_bulding'], 
    array('using' => array('soc_building_id', 'soc_building_name'), 
          "class" => "mandatory-field") );
$soc_bulding->setLabel("Buiding name" . REQ_FIELD);
$this->add($soc_bulding);

      

in the above code 'using' => array('soc_building_id', 'soc_building_name')

reflect soc_building_id

both the parameter value and the soc_building_name

actual text in the dropdown, but I want another property name in the same option field, which already tried to pass 3 parameters to an array, but it doesn't work.

+3


source to share


1 answer


Please use the below code and replace yours



echo $this->tag->select(array("users",
        Users::find(),
        "useEmpty"  =>  true,
        "emptyText" =>  "Please select",
        "using" => array("id", "name"),
     ));

      

+2


source







All Articles