interestingly enough, I actually came across this same need in my application.
From inside the controller, I added this line
$this->MyModel->validate['bid']=array('rule'=>array('range',$this->MyModel->minimum_bid-1,$this->MyModel->maximum_bid+1),'message'=>"Allowed range for bid is {$this->MyModel->minimum_bid} - {$this->MyModel->maximum_bid}");
if ($this->MyModel->save($this->data)) {...}
so the save function still runs the validate and I set the minimum and maximum bid during the beforeFilter
Hope this helps.
Alan
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.-------- Original Message --------
Subject: How to dynamically create validation rules
From: Kyle Decot <[email protected]>
Date: Fri, February 26, 2010 11:28 am
To: CakePHP <[email protected]>
I am creating an API for my website and I want to create validation
rules for my various methods based on some rows in my api_arguments
table. How should I go about doing this? Thanks for any help.
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
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
