Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 set array form field as required in model

If I have the following form field (code below) how can I set the field as required within my model so that like other fields the form cannot be submitted without it containing information.

<?= $form->field($model, 'seo[seo_title]')->textInput(['maxlength' => 60])->label('SEO Title') ?>
like image 764
Connor Brough Avatar asked Nov 10 '22 12:11

Connor Brough


1 Answers

Add the value for te textinput in the options eg:

 <?= $form->field($model, 'seo[seo_title]')->textInput(['maxlength' => 60], 'value'=> $yourValue )->label('SEO Title') ?>

or if you only need these fields required mark required in the model

like image 186
ScaisEdge Avatar answered Nov 14 '22 21:11

ScaisEdge