Hello, everybody! I am facing the problem that when data from the form invalidates, CakePHP inserts this under the invalidated form field:
[code]<div class="error-message">1</div>[/code] I can't get it from here. Now, this appears only when I invalidate field through validates() method. If I invalidate field through $validate field, it displays message defined with 'message' property in validation array. This makes me think about passing validation message through invalidate () method. However, this method is defined by: >> Model::invalidate ( $ field ) >> >> Sets a field as invalid >> >> >> Parameters: >> string $field The name of the field to invalidate so, there is no param to pass validation message. Somebody help me, please :). Here is sample code: user.php: [code]<?php class User extends AppModel { var $name = 'User'; var $validate = array( 'password' => array( 'rule' => '/.{6,}/', 'message' => 'Password must be at least 6 characters long.' ) ); function validates() { $user = $this->data['User']; if($user['password'] != $user['passwd']){ $this->invalidate('passwd'); } //Check for user existing $userEx = $this->findByUsername($user['username']); if (!empty($userEx['User']['username'])) { $this->invalidate('username'); } $errors = $this->invalidFields(); return count($errors) == 0; } } ?>[/code] and in user_controller.php [code][/function register() { if(!empty($this->data)) { if($this->User->save($this->data)) { $this->flash('You have succesfully registered.' , 'register', 2); } else { $this->set('errorMessage', 'Please correct errors below.'); $this->render(); } } } [code] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---