我将向dropDownList添加另一个属性.
我将使用Yii dropDownList这样的下拉列表:
<select name="city" id="city">
<option value="1" test="123">one</option>
<option value="2" test="234">two</option>
<option value="3" test="345">three</option>
<option value="4" test="456">four</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我将测试属性添加到选项标签.
默认Yii dropDownList是:
<?php
echo CHtml::activeDropDownList('City', 'City', array(1 => 'one', 2 => 'two'));
?>
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做?
Oro*_*ruk 11
试试:
<?php
echo CHtml::dropDownList(
'City',
'City',
array(1 => 'one', 2 => 'two'),
array('options' => array(
'1' => array('test' => '123'),
'2' => array('test' => '234'),
))
);
?>
Run Code Online (Sandbox Code Playgroud)