Twitter bootstrap yii select2插件预加载数据
如何在yii-select2的yii中设置预选数据,如本例所示 这是我的代码,我想为预选数据显示另一个数组Twitter bootstrap yii select2插件预加载数据,twitter-bootstrap,yii,jquery-select2,Twitter Bootstrap,Yii,Jquery Select2,如何在yii-select2的yii中设置预选数据,如本例所示 这是我的代码,我想为预选数据显示另一个数组 $this->widget('bootstrap.widgets.TbSelect2', array( 'asDropDownList' => false, 'name' => 'YumProfile[projectlist]', 'options' => array( 'multiple' => true, 'data' => $a
$this->widget('bootstrap.widgets.TbSelect2', array(
'asDropDownList' => false,
'name' => 'YumProfile[projectlist]',
'options' => array(
'multiple' => true,
'data' => $array,
'width' => '40%',
'tokenSeparators' => array('##', ' ')
)));
它看起来像是在使用YiBooster。我希望你试试这个:
$array = array(
'active' => 'Active',
'pending' => 'Pending',
'invited' => 'Invited',
'deleted' => 'Deleted'
)
$this->widget('bootstrap.widgets.TbSelect2', array(
'asDropDownList' => false,
'name' => 'YumProfile[projectlist]',
'data' => $array,
...
'htmlOptions' => array(
'options' => array( // selected options by default
'active' => array(
'selected' => true,
)
)
),
)
);
我也做了同样的事情,但方法有点不同。首先感谢您的重播!我的数据是这样的2d数组:
$array2=数组(数组(“id”=>“1”,“text”=>“mm”)、数组(“id”=>“2”,“text”=>“mm2”)、数组(“id”=>“2”,“text”=>“mm3”)<代码>如何为这些数组设置html选项,使其为selected=true?!好的,我明白了;)非常感谢,我正在改变我对数据的理解