I'm facing a stupid issue there but I'm sure it would be easy for you, master of javascript !
Here is my symfony form :
$form = $this->createFormBuilder()
->add('accept', 'checkbox', array('required' => false, 'label' => 'Do You Accept This News ?'))
->add('custom', 'textarea', array('required' => false, 'attr' => array('rows' => 10), 'label' => 'Attach a Custom Message'))
->add('line', 'integer', array('required' => false))
->add('Send', 'submit',array('attr' => array('class' => 'button')))
->getForm();
And here is my twig template rendering it :
<table>
<thead>
<tr>
<th>Time</th>
<th>Statement</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{% set count = 0 %}
{% for milestone in milestones %}
<tr>
<td>{{ milestone.createdAt | date('M-d H:i:s') }}</td>
<td><a href="{{ path('rudelist_entity',{'slug':milestone.idEntity.slug})}}">{{ milestone.idEntity.name}}</a>{{ newStatements[count] }}
</td>
<td>
<a class="button revealModal" href="#" data-reveal-id="myModalJournalist">Treat News</a>
<div id="myModalJournalist" class="reveal-modal" data-reveal>
{{ form_start(form) }}
<div class="marginBottom">
{{ form_widget(form.accept) }}
{{form_label(form.accept)}}
</div>
<div class="fieldContainer fieldTextareaContainer">
{{form_label(form.custom)}}
{{form_widget(form.custom)}}
{{form_errors(form.custom)}}
</div>
<div class="hide">
{{form_widget(form.line)}}
</div>
{{ form_end(form) }}
<a class="close-reveal-modal">×</a>
</div>
</tr>
{% set count = count + 1 %}
{% endfor %}
</tbody>
</table>
So the thing is, I'm displaying a button for each row, but they all open the same modal with an unique form, in which I have a boolean, a textarea and an integer field which I'm hidding because I want to auto-fill the "line" row of my form with the index of the row of the button that was click, so I would know with row I need to update. I've been trying that but unsuccessfully :
$(function(){
$("body").on('click','a.button.revealModal',function(){
var position = $(this).parents("tr").index();
$("#form").find("input#form_line").val(position);
});
});
Thanks for your help !