Brett
Brett

Reputation: 20079

Modify the template for Yii 2's error summary?

Is there anyway to modify the template for Yii 2's error summary?

For example I don't want it to show the text "Please fix the following errors:".

Upvotes: 0

Views: 5454

Answers (1)

Brett
Brett

Reputation: 20079

I found out it doesn't seem to really have a template, but that text is part of the header and you can get rid of it like this:

$form = ActiveForm::begin();
$form->errorSummary($model, ['header' => '']);
ActiveForm::end();

In my case I didn't want a header so I set it to a blank value; you can optionally change it to whatever you want.

Optionally you can also extend the ActiveForm class and create your own errorSummary method to pass in the options by default to the errorSummary method in it's parent.

Upvotes: 6

Related Questions