如何为下拉选项指定名称

时间:2015-04-28 07:32:01

标签: php phalcon

使用Phalcon框架,我有一个Form类文件,我在select文件中声明render.volt

$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);

在上面的代码中,'using' => array('soc_building_id', 'soc_building_name')反映soc_building_id作为选项值,soc_building_name实际文本位于下拉选项中,但我想在同一个选项框中再添加一个属性名称,已尝试过将3个参数传递给该数组但它无效。

1 个答案:

答案 0 :(得分:2)

请使用以下代码并替换您的代码

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