How to get input form type

前端 未结 5 1289
别跟我提以往
别跟我提以往 2021-01-03 23:46

I want get form field type and set class fot field type

i try:

{# Form field row #}
{% block form_row %}
{% spaceless %}
  
5条回答
  •  被撕碎了的回忆
    2021-01-04 00:38

    block_prefixes is used to generate block names to display field (cf FormRenderer::searchAndRenderBlock method). The most specific existing block in template (generally form_div_layout.html.twig file) will be displayed.

    So, the last item of block_prefixes is the id of your input, to allow you to override block for a specific field.

    Previous item will be the item you need.

    You can use this one : $form->vars.block_prefixes[$form->vars.block_prefixes|count -2] in smarty syntax.

提交回复
热议问题