Symfony gets form attributes

I know this is a stupid question, but I need to know if I can get the attributes of the form widget via PHP. I do not mean a value, but an id, a class, or even a parent or child. If I install them.

<label name = '{{ item.modulePath }}' id = 'main' class = 'menu_label' **parent = ''** **childs = ''**>{{ item.modulePath }}</label> 

If this is not possible, then how can I make a JS function before checking the form and columnar array in the form as a value?

 <form action="{{ path('menu_manage') }}" method="post"> 

Yes, I can get the values ​​and submit the JS form, and then JS get all the attributes, and then send it via ajax to the PHP handler. But it will be longer, because I will need to include all the components that have this action in the descriptor information in order to place it where I need it.

Here is an example of how to implement it.

http://symfony2forum.org/threads/5-Using-Symfony2-jQuery-and-Ajax

+4
source share
1 answer

You can call the get() method on the form field in the template, for example. having a form in form with an item field:

 {{ form.item.get('id') }} 

A class - only if set - can be restored as follows:

 {{ form.item.get('attr').class }} 
+1
source

Source: https://habr.com/ru/post/1386259/


All Articles