Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 disabled textInput ActiveForm

Tags:

yii2

how to disabled textInput in ActiveForm ? i try like this but can't

<?= $form->field($model, 'title_series')->textInput(['class' => 'form-control class-content-title_series', 'placeholder' => 'Title', 'disabled' => 'disabled'])->label(false) ?>

'disabled' => 'disabled or 'disabled' => true both of them can't too

like image 536
Caspian King Avatar asked Sep 14 '16 02:09

Caspian King


2 Answers

I don't really know yii2/ActiveForm, but I believe you need to do it this way:

<?= $form->field($model, 'title_series')->textInput(['class' => 'form-control class-content-title_series', 'placeholder' => 'Title', 'disabled' => true])->label(false) ?>
like image 191
Keith M Avatar answered Oct 27 '22 10:10

Keith M


To ensure that the field values are send on submit, use

echo $form->field($model, 'name')->textInput([
    'readonly' => true,
]);

This solution won in 50 different tries.

like image 26
WeSee Avatar answered Oct 27 '22 11:10

WeSee