Yii2 sets array shape field as required in model

If I have the following form field (code below), how can I set the field as required in 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') ?>

      

+3


source to share


1 answer


Add value

for text input in options, for example:

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

      



or if you only want these fields, the required labels required in the model

0


source







All Articles