Is there a way to (temporary) exclude associated records from validation?
For instance:
Just not including the Member model in the edit page for a Group isn't an option, because I need the members displayed on the page in a list.
I'm also wondering: what is the use of the validatesAssociated function, since there seems to be called a validation on the associated models anyway? Maybe I should only use validatesAssociated if I want an error returned? (which by the way is a generic ''Modelname is invalid')
Thijs, shouldn't Member validation rules be consistent regardless where those members belong?
Anyhow, you could use something like this on your Group model
function save()
{
$LoadedMembers = $this->members;
unset($this->members);
$result = parent::save();
$this->members = $LoadedMembers;
return $result;
}
validatesAssociated is just for quick checking loaded associates validity.
Works like a charm!
Thijs, shouldn't Member validation rules be consistent regardless where those members belong?
In a perfect world.. The problem is that Members are added first (with only a check on uniqueness of their e-mail address) and their details can be added later. And those details have to be validated because other, er.. more detailed details, depend on the first batch being entered.
But at the same time the Group details must be up-datable.
Anyway, hacking save() is not pretty, but the alternative would be to add custom validation methods (and use save(0) ) in several places.
Thanks Bermi!
1 to 3 of 3