I’m having some trouble with the unique_pair validation. It seems not to work when saving relationships.
in my model (in validation array):
'email' => array(
'label' => 'Email',
'rules' => array('required', 'trim', 'unique_pair' => 'gewinnspiel_id', 'valid_email')
),
“gewinnspiel_id” is a has_many to has_one relationship
I save my model like that:
$gewinnspiel_antwort->save($gewinnspiel);
And it saves doublicates, same email, same relationship ... should not validate but does.
I guess it adds the relationship after saving to the db, so it does not have the id to do the unique_pair check when saving.
The workaround is to add the relationship manually:
$gewinnspiel_antwort->gewinnspiel_id = $gewinnspiel->id;
and then just save it.
But i guess it would be nice if the validation would work without the workaround ... but maybe the saving process is designed in a way which would make it very tricky to solve that due to saving relationships after saving the data.
And btw, great work, i am using dmz about three days now and it already saved my life a dozen times!
greetings