yii2从dropdownlist

时间:2015-04-22 14:31:51

标签: forms yii2

如何从复选框字段

中删除optgroup
<?= $form->field($model, 'survey_type')->dropDownList([$surveyTypeList],['prompt'=>'Select Survey Type','id'=>'Survey_Type_dropdown']) ?>

提供以下html

<label class="control-label" for="Survey_Type_dropdown">Type</label>
<select id="Survey_Type_dropdown" class="form-control" name="Surveys[survey_type]">
<option value="">Select Survey Type</option>
<optgroup label="0">
<option value="2D">2D</option>
<option value="3D">3D</option>
</optgroup>
</select>

<div class="help-block"></div>

1 个答案:

答案 0 :(得分:9)

您必须将$surveyTypeList作为变量发送,而不是数组。

只需删除[]