Loading a row template for dynamic tabular input

If you have this form (for example) :




<?php $form = ActiveForm::begin(); ?>


    <table>


    <?php foreach($models as $model): ?>

        <!-- row template -->

        <tr>

            <td><?= $form->field($model, 'firstName'); ?></td>

            <td><?= $form->field($model, 'lastName'); ?></td>

        </tr>

        <!-- // row template -->

    <?php endforeach; ?>


    </table>


<?php ActiveForm::end(); ?>



Now, what is the best way that you’d use to get a copy of the code (template) between &#60;&#33;-- row template --&#62; and &#60;&#33;-- // row template --&#62;, so you can use it to add new rows dynamically using JavaScript?

Currently working on the same issue.

There are solutions but you have always to make a compromise somewhere.

Take a look at:

http://www.yiiframework.com/forum/index.php/topic/53537-dynamic-tabular-input-form/

Regards