I do not agree to violate the MVC logic. I also tried using all the array('escape' => false) possible paths (in Form-> input, in Form-> error and even in the model), and none of them worked with me! (cakephp 2.0)
The answer "Anh Pham" is the easiest and easiest way. In addition to this, I returned an empty error message from the model check ('errorMessage' => false; does not work in cakePhp 2.0).
Since I wanted to pass the variable to the view in order to build the link there (MVC), in the controller , I check if the field was invalid:
$invlaidFields = array_keys($this->Model->validationErrors(); if ( in_array('myField', $invalidFields) ){ ... }
In view I check to see if this field has been invalidated, and then echo my error message sending a class error message, so it looks the same as the rest of the error messages.
if ($this->Form->('myFields')) { ... echo '<span class="error-message">error message'. $this->Html->link(...).'</span>'; }
Hope this helps someone out there.
PS It is always useful to mention which version of cakePHP you are using ...
source share