YII - 向 dropDownList 添加另一个属性 [英] YII - Add another attribute to dropDownList
本文介绍了YII - 向 dropDownList 添加另一个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将向 dropDownList 添加另一个属性.
I will to add another attribute to dropDownList.
我将使用 Yii dropDownList 制作一个这样的下拉列表:
I will a dropdown list like this with 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>
我将在选项标签中添加 test 属性.
I will add test attribute to option tags.
默认 Yii dropDownList 是:
Default Yii dropDownList is:
<?php
echo CHtml::activeDropDownList('City', 'City', array(1 => 'one', 2 => 'two'));
?>
我该怎么做?
推荐答案
尝试:
<?php
echo CHtml::dropDownList(
'City',
'City',
array(1 => 'one', 2 => 'two'),
array('options' => array(
'1' => array('test' => '123'),
'2' => array('test' => '234'),
))
);
?>
这篇关于YII - 向 dropDownList 添加另一个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文