1

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

1 Answer 1

2

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

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

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

  ....
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer! Actually I need this <?= Html::error($post, 'title', ['class' => 'error']) ?> and your answer helped me find this
Sorry bro! I forgot it and I am new here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.