CakePHP Multi-record forms

While developing a registration form for a client I had the following problem:
This form needed to be able to grab multi-record values for one table. In this case I had a form where a person could sign up more than one participant. (Using CakePHP standard form names)

echo $form->input('Participant.0.first_name');
echo $form->input('Participant.0.last_name');
echo $form->input('Participant.1.first_name');
echo $form->input('Participant.1.last_name');

CakePHP has a really great saveAll feature which allows you to validate and save to multiple models (tables). In this case though I don’t want to save the data immediately to the database. I am using the Wizard component which saves all of the form data to an array to be used later.

Simply using the validates() function doesn’t work in this case because of the multiple records. In the docs it says there is an open for saveAll validate’=>’only’ but I couldn’t get that to work either.
After Googling I found this post: and was finally able to make some progress.
For the view code example above I used the following for my controller:

$invalidBookFields = array();
foreach($this->data['Participant'] as $index => $participant) {
$participant = array('Participant' => $participant);
if (!$this->Participant->validates()) {
// save the validationErrors and reset for the next iteration
$invalidBookFields[$index] = $this->Participant->invalidFields();
if (empty($invalidPartFields)) {
return true;
else {
// put all the errors back in the model so they make it back to the view
$this->Participant->validationErrors = $invalidPartFields;
return false;

And now it validates according to the $validate array in your model. Yay!