Hello,
I’ve been looking at the API and searched the forum several times, but couldn’t find a solution for this.
In view files, when I display errors I use
<?php $form->error($model, "id"); ?>
This displays an error message if error is set by the Controller $this->addError("id", "This is an error");.
Is there a way for me to see if there’s an error with certain name?
For example, in my login, I have a field which is "active" to see if the user is activated or not (through email address confirmation). And if the user is not activated, I display an error message $this->addError("activate", "This user account is not activated."). But in view files, I want to check if error has been set for "activate", and display additional messages like this.
<?php if($form->ErrorExists($model,"activate") === true) {
echo "In order to re-send an email, press here".someurlhelperfunction."or submit another valid email address here".(display form using form helpers, etc.;
}
?>
I’ve thought about doing something like
if($form->error($model,"activate") contains "this user account is not activated"…)
or
$this->addError("activate", $string which contains all the information, including form);
but they both seem not as clean, and second option definitely does not separate view from controller.
Thank you very much for your help!