Yii2 Active Record Hidden Active Form Field or How to Hide an Active Form Field

Here’s a small tip on how to create a hidden field in an active record form, within the model: <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, ‘fullname’)->textInput([‘maxlength’ => true]) ?> /* Example of hiddenInput for an ActiveRecord Active $form->field */ <?= $form->field($model, ‘state’)->hiddenInput([‘value’=> $src->state])->label(false);?> <?= $form->field($model, ‘position_str’)->textInput([‘maxlength’ => true]) ?> <?php ActiveForm::end(); ?>

Read More