I'm trying tu use Dardo Sordi MultivalidatableBehavior (http://
bakery.cakephp.org/articles/view/multivalidatablebehavior-using-many-
validation-rulesets-per-model).

I have a form where, depending on the value of a field (a select box),
I want to validate one or another field.

The select box is monitored by ajax->observeField that, on a change
runs a function in the controller:

        function update_div()   {
                if(!empty($this->data)) {
                        //code to find something (omitted). The result
in $options
                        if ($options!='')
                        {
                                $this->Mymodel->setValidation('myrules');
                                }
                        else
                                $this->Mymodel->restoreDefaultValidation();
                }
        }

myrules and the default rules are defined in the model. The default
rules work as expected, myrules don't.
I tried to trace the problem in the code and in update_div $this-
>Mymodel->validate seems to have the correct value but I put a log
line in beforeValidate() (in the model) and the validate property is
not equal to myrules but it has the default rules value. :-(

I don't understand if it is wrong to change the validation rules in my
function (started by ajax) and what method or function changes the
validate property after it is set in my update_div() function.

Any suggestion?

Thanks
    maxx

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to