How to add dynamic field to the value in the form?

Hi all. There is a function:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
 $(document).ready(function () {
$('#add').click(function(){
 var str = '<div>';
 str+= '<input type="text" value=""/> ';
 str+= '<input type="button" value="-" class="remove"/>';
$('#sites').append(str);
});
 $('.remove').live('click', function() {
$(this).parent('div').remove();
});
});
</script>

It adds an empty field in the div below:

echo CHtml::openTag('div', ['id' => 'sites']);
echo CHtml::closeTag('div');


How can I change it to added field in this format:

echo $form->dropDownList($door,'type',$door->typeList(),
 ['name' => DoorSale::class.'[type]['.$door->id.']']);
March 19th 20 at 08:49
1 answer
March 19th 20 at 08:51
This:
echo $form->dropDownList($door,'type',$door->typeList(),
 ['name' => DoorSale::class.'[type]['.$door->id.']']);

php. The widget generates html, so You should just render the html and copy it, then paste in the js. But the widget still js for validation of the registers, so I'm not sure You have what You ask for.
It is possible, perhaps you need something else but I can't understand that) - ryan_Stanton commented on March 19th 20 at 08:54

Find more questions by tags YiijQuery