> I don't know how cake's implement the 'on' => 'create' or 'update' rules, > but maybe you can sort of extend that to add more states, like 'on' => > 'logged'.
This is how cake processes the 'on' attribute (in the current version, this might change?) * If the 'on' attribute is missing or null, zero or false, the rule is always processed * If the 'on' attribute is 'create', the rule is processed if and only if the record does not exist * If the 'on' attribute is 'update', the rule is processed if and only if the record exists * Otherwise, the rule is not processed So yes, you *could* extend the 'on' parameter, but it might be tricky remembering past states. Having 2 validation arrays can also be neat, see here : http://groups.google.com/group/cake-php/browse_thread/thread/6c2c27bbcdcb4e33 Of course, if you need to share rules across validation cases then this isn't very DRY either... On Feb 5, 1:27 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote: > Have 2 validate arrays and create a function in the model that let you choose. > > On Feb 5, 2008 9:59 AM, Matias Lespiau <[EMAIL PROTECTED]> wrote: > > > Maybe you can create a behavior. That way you control which models has those > > validation rules available. > > > I don't know how cake's implement the 'on' => 'create' or 'update' rules, > > but maybe you can sort of extend that to add more states, like 'on' => > > 'logged'. > > > Cheers, > > > On Feb 3, 2008 10:13 AM, cronet <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > how realising case by case validation ?? (e.g. A form need to validate > > > different for a user logged in, or not logged in) > > > > First, I thought about creating two different Models with the > > > different validation cases. > > > But what about the funcitons I need for the models which I would pack > > > in the model itselfs. So I would need to create the same functions in > > > both models... Not really DRY... > > > In app_model these functions would be available in all models, which i > > > don't prefer... > > > > What would be a more elegant way to handle case by case validations ? > > > > Regards, > > > Alexander > > > -- > > Matias Lespiau > >http://www.gignus.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
