Friday 15 June 2012

symfony - How to set a css class of the widget type with Symfony2 -


Depending on the input type, is there any way to implement a specific class on the root drive of an input?

ex .:

  & lt; Div class = "radio-input" & gt; & Lt; Input ... .... & lt; / Div & gt;   

I tried to overload "fields.html.twig" with it:

  {% block form_row%} {% spaceless%} {% set Type = type | Default ('text')%} & lt; Div class = "{{type}} - input" & gt; {{Form_label (form)}} {{form_errors (form)}} {{form_widget (form)}} & lt; / Div & gt; {% Endpaceless%} {% endblock form_row%}   

But "type" is always equal to "text."

There is no particularly good solution, but it seems that block_prefixes Block form_row has been blocked. Block_prefixes is an array of form field types in order of inheritance, so the first name in a text field will be like the block_profile array:

block_prefixes = array ("form", "field", " This means that you can get the second from the previous array element and use it:

  {% block form_row%} {% Spaceless%} 
{{form_label (form)}} {{form_errors (form)}} {{form_widget (form)} } & Lt; / div & gt; {% Endpaceless%} {% endblock form_ Row%}

I'm sure there are better ways than this, though it is not in my mind.

PE type is undefined This is why it is always your For text as you like it in the default text

No comments:

Post a Comment