Re: beforeSave vs beforeValidate

2010-03-13 Thread j0n4s.h4rtm...@googlemail.com
It depends, it depends on your use case. For instance if one may enter text into a huge textfield, maybe richtext for instance, its better to sanitize after READING it from the database, not upon writing (beforesave). If you want to change things on the fly before validation its no problem. For i

Re: beforeSave vs beforeValidate

2010-03-12 Thread Dr. Loboto
The flow is beforeValidate -> validate -> beforeSave -> save First beforeValidate() callback is to check data and make global decision go further / this data cannot be validated/saved. If answer is no save() immediately returns false. If beforeValidate() was successful actual validation occurs. If

beforeSave vs beforeValidate

2010-03-12 Thread Dave
Most tutorials or tips online refer to before Save () as a good before saving to clean data and what not but never have i seen anything on beforeValidate as beforeValidate seems to be better to use i would think. No? For example city has validation rules say min 5 characters if someone enters "b"

Re: beforeSave vs beforeValidate

2009-12-03 Thread naidim
It appears that's it. Thank you. "beforeSave: Called before each save operation, after validation. Return a non-true result to halt the save." On Dec 2, 9:38 am, "j0n4s.h4rtm...@googlemail.com" wrote: > Check what those methods have to return, at least(maybe both) one of > them (I "think" it was

Re: beforeSave vs beforeValidate

2009-12-02 Thread j0n4s.h4rtm...@googlemail.com
Check what those methods have to return, at least(maybe both) one of them (I "think" it was beforeSave) has to return true; On Dec 1, 10:46 pm, naidim wrote: > Sorry, I meant to say the code is in the user MODEL not controller. Check out the new CakePHP Questions site http://cakeqs.org and help

Re: beforeSave vs beforeValidate

2009-12-01 Thread naidim
Sorry, I meant to say the code is in the user MODEL not controller. 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,

beforeSave vs beforeValidate

2009-12-01 Thread naidim
When I use this function as beforeValidate in users_controller it works. When I change it to beforeSave (and remove the parent::beforeValidate(); call) it returns to /users/edit (built via scaffolding) with a flash "Please correct errors below." with no errors identified in the form. Slug has no va