I have a form with the following fields:
- firstName
- lastName
- emailAddress
followed by (up to) ten name/email fields, like so
- friendName-1
- friendEmail-1
- friendName-2
- friendEmail-2 ... etc.
The firstName, lastName & emailAddress fields will be saved into a 'referrals' table, but 10 name/email pairs will go into a 'friends' table, containing a foreign key refferal_id.
Normally I use the cakephp 'automagic' forms, and set up my validation in the model, and do a $this->model->save();
If it fails I fall back on my model validation rules and the error messages get spat back into my form html. No problems.
How would I do this for TWO tables though? I'm thinking that the automagic stuff is not the way to go, but I feel I will lose a lot without it, such as validation in my models and custom error messages.
Is there a happy medium? I'm fairly new to cake so I'm wondering if theres a way to use automagic with multiple tables.