Hmmm... My earlier reply appears to have got lost. Thanks for the advice. I worked it out. It was because the relationship was a hasMany & I'd forgot to add the .0. into the field name.
T On Dec 2, 8:43 am, AD7six <[email protected]> wrote: > On Thursday, 1 December 2011 18:05:57 UTC+1, Toby G wrote: > > > Hi there, > > > Version: 1.3.12 > > > I seem to be having a problem with the 'numeric' validation rule on an > > associated Model's fields. For some reason it is not validating '10' > > as a valid numeric value. > > > Here are the validation rules for the (PhysicalTicket) no_of_tickets > > field in question... > > > 'no_of_tickets' => array( > > 'numeric' => array( > > 'rule' => array('numeric'), > > 'message' => 'Please provide the number of tickets you require', > > 'allowEmpty' => false, > > //'required' => false, > > //'last' => false, // Stop validation after this rule > > //'on' => 'create', // Limit validation to 'create' or 'update' > > operations > > ), > > 'between' => array( > > 'rule' => array('between', 1, 9), > > the between rule is checking number of characters, not numeric value > > > > > > > > > > > 'message' => 'Please provide the number of tickets you require > > (between 1 & 9 can be booked at a time)', > > 'allowEmpty' => false, > > //'required' => false, > > //'last' => false, // Stop validation after this rule > > //'on' => 'create', // Limit validation to 'create' or 'update' > > operations > > ), > > ), > > > And here is the data being validated (using saveAll)... > > > Array > > ( > > [Booking] => Array > > ( > > [event_id] => 17 > > [booking_type] => is_physical_tickets > > [post_to_wall] => 1 > > ) > > > [PhysicalTicket] => Array > > ( > > [name] => Toby Griffiths > > [phone_no] => > > [no_of_tickets] => 10 > > ) > > > [submit] => Request tickets > > [add_more_text] => SOMETHING RANDOM > > ) > > > The validation error show is "Please provide the number of tickets you > > require" rather than the expected "'Please provide the number of > > tickets you require (between 1 & 9 can be booked at a time)" > > There's probably something else at play here, like e.g. the value of > no_of_tickets not actually being in the data that's being validated and > therefore !notEmpty - I'd suggest sticking debug($something) in cake > somewhere. e.g. in function numeric, in Validation, or in Model's validate > logic. > > AD > > > > > > > > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
