Have you already tried to deactivate all rules except one and find out which of them is causing the trouble?
Anja -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Nature Lover Gesendet: Mittwoch, 7. Januar 2009 07:48 An: CakePHP Betreff: Validation Failed even while entering correct data. Please help! Hi! This post is long due to code referred, the problem might be small for others. I am a newbie and have implemented validation rules for site_admin_id, email, password and main [enum type] fields. But while submitting the form it fails when even entered correct data. The rules are specified as below: var $validate = array( 'site_admin_id' => array('numeric'), 'email' => array( 'email' => array( 'rule' => array('email',true), 'message' => 'Invalid' ), 'notEmpty' => array( 'rule' => 'notEmpty', 'message' => 'Required' ), 'isUnique' => array( 'rule' => 'isUnique', 'message' => 'Already registered', 'on' => 'create' ) ), 'pass' => array( 'alphaNumeric' => array( 'rule' => 'alphaNumeric', 'message' => 'Alphabets and Numbers only' ), 'notEmpty' => array( 'rule' => 'notEmpty', 'message' => 'Required' ), 'between' => array( 'rule' => array('between', 6, 12), 'message' => '6 to 12 characters' ) ), 'main' => array( 'inList' => array( 'rule' => array('inList', array('y', 'n')), 'message' => 'y or n' ) ) ); while using following code in controller to save the data: if (!empty($this->data)) { $this->data['AccountUser']['site_admin_id'] = '1'; $this->data['AccountUser']['main'] = 'y'; $this->data['Account']['site_admin_id'] = '1'; $this->data['Account']['account_category_handle'] = 'retail'; $this->data['Account']['price_book_code'] = 'retail'; $this->data['Account']['first_name'] = $this->data['AccountUser'] ['first_name']; $this->data['Account']['last_name'] = $this->data['AccountUser'] ['last_name']; $this->data['Account']['approved'] = 'y'; $this->data['AccountAddress']['0']['account_address_category_handle'] = 'billing'; $this->data['AccountAddress']['0']['site_admin_id'] = '1'; $this->data['AccountAddress']['1']['account_address_category_handle'] = 'shipping'; $this->data['AccountAddress']['1']['site_admin_id'] = '1'; if($this->data['AccountAddress']['1']['same']==1) { $this->data['AccountAddress']['1']['address1'] = $this->data ['AccountAddress']['0']['address1']; $this->data['AccountAddress']['1']['address2'] = $this->data ['AccountAddress']['0']['address2']; $this->data['AccountAddress']['1']['city'] = $this->data ['AccountAddress']['0']['city']; $this->data['AccountAddress']['1']['zip'] = $this->data ['AccountAddress']['0']['zip']; $this->data['AccountAddress']['1']['state_abbrivation'] = $this->data ['AccountAddress']['0']['state_abbrivation']; $this->data['AccountAddress']['1']['country_iso2'] = $this->data ['AccountAddress']['0']['country_iso2']; $this->data['AccountAddress']['1']['phone'] = $this->data ['AccountAddress']['0']['phone']; $this->data['AccountAddress']['1']['fax'] = $this->data ['AccountAddress']['0']['fax']; } $this->Account->create(); if($this->Account->saveAll($this->data,array('validate' => 'only'))) { $this->data['AccountUser']['pass'] = md5($this->data['AccountUser'] ['pass']); //if($this->Account->saveAll($this->data, array('validate' => false))) //{ $this->redirect(array('action' => 'registered', 'id' => $this- >Account->id)); } //else //{ $this->set('errorHeading', 'Registration failed due to some server error. Please try again!'); } $this->set('errorHeading','Valid'); } else { $this->set('errorHeading','Please correct the errors in form!'); } } For Account and AccountAddress models validation works perfectly, but in case of AccountUser it gives error as: site_admin_id => This field cannot be left blank [assigned value '1' before validation] email => Invalid [provided correct in form as '[email protected]'] pass => Alphanumeric only [provided 'abc123' in form] main => y or n [assigned value 'y' before validation] In debuging SQL queries it shows the email address got converted to \[email protected] I failed to find the fault from last three days working to resolve this. Please Help! Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
