One model one view multiple tabular input sets

Have to collect tabular input data from two places in a page ( say top half and bottom) and from the same model.

For this i created 2 arrays of model say (top=>almodel, bottom=>almodel1) and passed it to view.

Then withing a single form looped through both of them individually and created their tabular form.

The problem is while submitting only the data from the bottom tabular input data gets submitted.

Any idea what I should be doing or what am i doing wrong ??

By default data is sent as an associative array with key represented as model name:



so - when you post two models of same type - the second one will overwrite values of the first one. I don’t know if it is the only solution, but you can always specify names of HTML form elements by hand like this:

CHtml::activeTextField( $model1, ‘attribute1’, array( ‘name’=>‘model1[attribute1]’ ) );

CHtml::activeTextField( $model2, ‘attribute1’, array( ‘name’=>‘model2[attribute1]’ ) );

and then reference it from PHP like this:

$model1->attributes = $_POST[‘model1’];

$model2->attributes = $_POST[‘model2’];

hope this helps :)