Create unlimited model in the same view.

Hello everyone,

I have a table that has three fields:





I want add unlimited phones pressing the Create button, make me insertion at all. I need a button that when pressed with javascript it create the two fields (phones_name and phones_ref).

Can you help me please basically my question is how to do it with all ActiveForm and validation.

My main question is that controller must create each new model before rendering the view, however we do not know how many models will create because this is decided by the user in the view.

The guide provides some inspiration for that:

Hello Thank you for your answer. My script is working correctly, however the client side validation in the fields create dinamically doesn’t work. ¿Can you help me?

I think that is because the validationrules aren’t load when the page si rendered. I read about activerform

$('#w0').yiiActiveForm('add', 'ProvSubc[45][prsu_cate_id]'); 

But it doesn’t work. Also I think that the validation in the new fields should be the same in the model. ¿is possible do it automatically?