我这样做。
<?= $form->field($model, 'HRMS_candidateStatus')->dropDownList($candidateStatus, [ 'prompt' => 'Select candidate status','class'=>'form-control input-sm',['disabled' => $model->isNewRecord] ]) ?>
我希望仅在创建模式下禁用下拉列表。我怎么能这样做?
答案 0 :(得分:2)
尝试添加true
或disabled
和false
:
<?= $form->field($model, 'HRMS_candidateStatus')->dropDownList($candidateStatus, [ 'prompt' => 'Select candidate status','class'=>'form-control input-sm',
'disabled' => $model->isNewRecord ? true : false ]) ?>
答案 1 :(得分:0)
使用已禁用的Html作为条件
<?= $form->field($model, 'HRMS_candidateStatus')->
dropDownList($candidateStatus, [ 'prompt' => 'Select candidate status','class'=>'form-control input-sm',
['disabled' => ($model->isNewRecord) ? 'disabled' : false] ]) ?>