yii2 hidden input value

David picture David · May 10, 2015 · Viewed 104.4k times · Source

In Yii2 I'm trying to construct hidden input

echo   $form->field($model, 'hidden1')->hiddenInput()->label(false);

But I also need it to have some value option, how can I do that ?

Answer

TimLeary picture TimLeary · Sep 9, 2015

Use the following:

echo $form->field($model, 'hidden1')->hiddenInput(['value'=> $value])->label(false);