dongliu0823 2013-12-19 16:06
浏览 54
已采纳

在Twig中获取表单的名称

How can I get the name of form (FormType.php)

i try with

{{ form_row(id) }}
{{ form_row(form.name) }}
{{ form.get('full_name') }}
{{ form.get('id') }}

I want get this

 /**
     * @return string
     */
    public function getName()
    {
        return 'my_form';
    }

and use in

{{ form_start(form, {'action': path('url'), 'method': 'POST', 'attr': {'id': NAME OF getName}}) }}

or if I can set id from formtype.php

  • 写回答

1条回答 默认 最新

  • doufei2194 2013-12-19 16:29
    关注

    You can get it like this:

    {{ form.vars.id }}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?