I am using macros in my twig to achieve the dynamically adding rows functionality the macro part of it is as follows:
{% macro macroLeave(item, hrisFlag) %}
<tr>
<td width="28%" align="left" height="30" bgcolor="#f6f6f6">
{{ form_widget(item.leaveType) }}
{{ form_errors(item.leaveType) }}
</td>
</tr>
{% endmacro %}
necessary javascript snippets is given below:
var addLeaveRow = function()
{
var index = $('#tblLeave tbody tr').length;
var row = $('script[name="scriptLeave"]').text().replace(/\$\$name\$\$/g, index);
$('#tblLeave tbody').append(row);
}
Can anybody suggest a way to achieve this functionality?
Here’s one way of doing it: