如何在Yii2中添加具有禁用值的占位符?

时间:2017-05-09 12:07:35

标签: yii2

我需要在输入字段中添加一个带有禁用值的占位符。我做错了什么?

<?= $form->field($category, 'id')->dropDownList($categoryList, [
    'options' => ['id'=>'category-id'],
    'placeholder' => 'Select category', [
        'disabled' => true,
     ]
 ]); ?>

1 个答案:

答案 0 :(得分:0)

<?= $form->field($category, 'id')->dropDownList($categoryList, 
         [
              'id'=>'category-id',
              'prompt' => 'Select category', 

              // This is experimental
              'options' => [
                   '' => ['disabled' => true],
              ]
         ]
); ?>