I am trying to use javascript inside Symfony and then I got a problem. The problem is located at my file twig.html. At the begining I had this code:
{{ form_widget(form.name, {'attr': {'class': 'form-control'} }) }}
Then I change it to this in order to use dynamic validation(that was the same code generated in browser, I just add onkeyup action)
<input type="text" id="person_name"
onkeyup="myFunction()" name="person[name]" required="required"
class="form-control" />
Then I was happy because my validation rules work, but I discovered that when I want to update to form. The field name is empty (but in the server it's good). So I would like to get this field. In my function updateAction I dump variable person before handling the form and then name was containing the good element. So the problem is there is a difference between form_widget and the good I just did. I would like to do a thing like this to get my field name:
<input type="text" id="person_name"
onkeyup="myFunction()" name="person[name]" required="required"
class="form-control" value="if(form.name is not empty) form.name"/>
Thank you.
{{ form_widget(form.name, {'attr': {'class': 'form-control', 'onkeyup': 'myFunction()'} }) }}