如何将类名或数据-* 添加到 widgetof "nex/yii2-chosen"

我正在使用“nex/yii2-chosen”,我们如何在下面的示例中添加“class”属性或“data-*”


<?=

$form->field($model, "vehicle_id")->widget(Chosen::className(), [

    'items' => $VehicleList,

    'disableSearch' => 5,

    'class' => 'vehicle_id form-control input-sm',    <---------------not working

    'clientOptions' => [

        'search_contains' => true,

        'single_backstroke_delete' => false,

    ]

]) ?>


手掌心
浏览 66回答 1
1回答

蝴蝶不菲

您只需要将它们放在options财产中即可。<?=$form->field($model, "vehicle_id")->widget(Chosen::className(), [&nbsp; &nbsp; 'items' => $VehicleList,&nbsp; &nbsp; 'disableSearch' => 5,&nbsp; &nbsp; 'options' => [&nbsp; &nbsp; &nbsp; &nbsp; 'class' => 'vehicle_id form-control input-sm',&nbsp; &nbsp; ],&nbsp; &nbsp; 'clientOptions' => [&nbsp; &nbsp; &nbsp; &nbsp; 'search_contains' => true,&nbsp; &nbsp; &nbsp; &nbsp; 'single_backstroke_delete' => false,&nbsp; &nbsp; ]]) ?>
打开App,查看更多内容
随时随地看视频慕课网APP