G'ofur N
G'ofur N

Reputation: 2652

Adding error in yii2 to html form

I want to add yii2 default error to the form that is created using only html tags:

<form>
   <input type="text">
</form>

I just shorted the form. Actually it is very long and couldn't write with

<?=  $form->field($model, 'model')->dropdownList([
        1 => 'item 1',
        2 => 'item 2'
    ],
    ['prompt'=>'Select Category']
    );
?>

<?= $form->field($model, 'model')->textInput() ?>
<?= $form->field($model, 'model')->textarea(['rows' => '6']) ?>

even if I used costom template for each one. Because the design is very complex

Upvotes: 1

Views: 347

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133370

You can use the $form->errorSummary($model) eg:

 <?php $form = ActiveForm::begin(); ?>
 .......

 <?= $form->errorSummary($model); ?>

  ....

Upvotes: 2

Related Questions