Is there a complete list of variables that can be used in form_div_layout.html.twig?

前端 未结 4 607
轮回少年
轮回少年 2021-02-01 10:44

I want to get all the variables available in the Symfony form theme file form_div_layout.html.twig, I read the Symfony official documention and searched on the web, but couldn\'

4条回答
  •  北海茫月
    2021-02-01 11:11

    Well, you can get all the available variables in each block by iterating the context:

    {% block form_widget_simple %}
    
      {% for key, value in _context %}
    1. {{ key }}
    2. {% endfor %}
    {% spaceless %} {% set type = type|default('text') %} {% endspaceless %} {% endblock form_widget_simple %}

    And if you want to use yours, then you'll have to overwrite the classes that actually are rendering those widgets, just take a look at AbtractType::buildView...

    As @Gregoire suggested, you can use {{ dump(_context) }} from version 1.5 (http://twig.sensiolabs.org/doc/functions/dump.html), but be aware that it will print a big amount of info.

提交回复
热议问题