Hello all.
I have a problem with displaying error messages after form validation.
Model user.php:
var $validate = array(
'fname' => array(
'rule' => array('custom','/^[A-Za-z\ ]{2,30}$/'),
'message' => 'Supply real first name',
'allowEmpty' => false,
),
'lname' => array(
'rule' => array('custom','/^[A-Za-z\ ]{2,40}$/'),
'message' => 'Supply real last name',
'allowEmpty' => false,
),
);
In controller, I use $this->User->set($this->data) and $this->User-
>validates() to validate inputs.
If form hasn't been filled correcty $this->validateErrors($this->User)
returns invalid fields.
The problem is, error message, with the use of:
$form->error('fname') or $form->error('lname')
is not displaying.
Model is validated correctly (it returns information that "fname" or
"lname" are not correctly filled, it even creates "<div class="error-
message"></div>" div for both fields. But there is no message in the
div.
When I type:
$form->error('fname','Supply real first name')
error message is displayed.
But I don't want to put error messages in the view. I rather want to
hold it in model's $validate variable.
What do I do wrong? Or maybe it's some king of bug in 1.2.6?
Many thanks in advance:)
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en