place your validation logic inside beforeValidate callback.
I would write a custom validation method for this purpose: http://book.cakephp.org/view/150/Custom-Validation-Rules#Adding-your-own-Validation-Methods-152
How are your fields being generated? I assume you're using something like:
<?php echo $form->input('Friend.name'); ?> [html stuff] <?php echo $form->input('Friend.email'); ?>
Since doing that several times within a page will produce duplicate ids (like, "FriendName
" would be the resulting ID for each field generated by <?php echo $form->input('Friend.name'); ?>
), you're probably going to have to add a number to each field name as you're generating them and then loop over $this->data['Friend']
in your controller and invalidate the offending fields as you find them (if the name is present, but the email is not, as you say).
I don't think there's a built-in way for cake to handle a situation like this, but I've been wrong before!