Better definition between model array and form array in forms

Hi,

This is only an idea and I am sure the way it is currently done is for a reason, however, today I came to writing a JS enabled title contributor list where everything was powered by the items on the form, from removing to adding (so basically no AJAX). I found one major problem when trying to implement this robustly.

The main problem is that variable[] notated form fields only act as model arrays. There is no way to define form only arrays that relate to none array model variables. This was a problem when I came to write my initial foreach() to represent this form:




<?php

       $i =0;

       foreach($model->contributors as $titleContributor){ ?>

       <div class="contributor">

   	       <?php $contributor = $titleContributor->getContributor();

		echo $contributor->first_name." ".$contributor->last_name;

		echo $form->hiddenField($titleContributor, "contributor_id[]", array("style"=>"display:none;"));

		echo $form->dropDownList($titleContributor, "role[]", TitleContributors::getRoles()); ?>

		<a href="#" class="Title_Contributor_Remove">Remove</a>

	</div>

	<?php $i++;

} ?>



The attributes in this form did not fill since Yii was expecting to pick the values from an array in the model (I guess). In reality what I wanted was for the attributes to fill from the active model’s attribute without the [] so that the $_POST would come in on the other side:




array("contributor_id"=>array(1, 2, 3), "role"=>array(1, 2, 3))



Since I could not do this I was forced to resort to []attribute notation for my form fields making:




array(array("contributor_id"=>1), array("role"=>1), //another contributor)



This style has made my code a little slower than what I originally intentioned when not using AJAX.

What would be good is for yii to take a mongo like dot notation with model arrays so to define a form field as a model array:


"model.array.0"

But then to define that something should be an array in post but should take its value from the current model being looked at:


"model[]"

Or something like that.

Thanks,