How to use Multiple instances of the same model in the same form

Comparing #5 with #6

Revision #6 was created by kiran sharma kiran sharma on Aug 3, 2012, 9:24:16 AM.

comment added

Content

[...]
{
$addressModel_1->attributes=$_POST['Address'][1]; // Set attribute for home address
$addressModel_2->attributes=$_POST['Address'][2]; // Set attribute for company address
$model->attributes=$_POST['User']; // Set attribute for user data

$valid=$addressModel_1->validate();
  // Validate all three model
$valid=$addressModel_2->validate() && $valid;
$valid=$model->validate() && $valid;
[...]
$model->attributes=$_POST['User']; // Set attribute for user data

$valid=$addressModel_1->validate();
 // Validate all three model
$valid=$addressModel_2->validate() && $valid;
$valid=$model->validate() && $valid;

if($valid)
{
[...]