I’d like to limit the number of validation errors that are displayed. I do not want a user who submits an empty form to see 20 or so error messages, but, say, only the first 3.
I do not have write access to $form->errors. So how how could I accomplish this task?
Instead of using CHtml::errorSummary($model) in your view, You’re probably going to have to create your own error box and get the error array via $model->getErrors(). You can then create a forloop which iterates only three times, something like this:
It’s hard if you don’t have write access to the model’s errors, otherwise you could just remove all but the first three errors from the model manually. Maybe you should use normal input fields instead of active input fields, though that would mark no input fields at all. Is that a big problem?
The problem above is not only about errorSummary but also the errors for each input field/label. Moreover how would you specify with your solition which 3 errors you want to have back? It’s not much use, if they come back randomly…