On May 26, 12:57 pm, Braindead <[email protected]> wrote:
> Why do you call save when validation in the controller fails?
> Save validates your data using the validation rules in your model. If
> you want to do some extra validate in your controller, you should make
> sure, that you don't call save when the extra validation fails.
As you suggest, I'm now using:
if ($this->Item->validates() && $this->Item->save($this->data)) {
(Note that this hack only works when I leave out the $this->Item-
>create() statement. I'm not sure what the consequences for that are)
As I mentioned before, this would not be required as save only saves
when it passes validation.
> Did you setup validation rules in your item model? Check the Cookbook
> for help on that topic:http://book.cakephp.org/view/125/Data-Validation
> For validation inside your controller you should check this
> link:http://book.cakephp.org/view/410/Validating-Data-from-the-Controller
I did not setup validation rules.
The underlying problem is that I only want two fields to be validated
if another field has a certain value.
Is it possible to add validation rules 'on the fly'?
Bram
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---