Symfony2 - form_start function customise in twig

后端 未结 1 1685
孤城傲影
孤城傲影 2021-02-05 03:49

Form helpers form_start and form_end are useful in twig:

{{ form_start(form) }}
{{ form_end(form) }}

I can customise

相关标签:
1条回答
  • 2021-02-05 04:40

    As form_start has the following signature,

    form_start(view, variables)
    

    And as class doesn't represent a valid variable name. You need to specify your class as a key/value array using the attr attribute.

    Then, try ...

    {{ form_start(form, {'action': 'myaction', 'attr': {'class': 'your_class_name'}}) }}
    

    Also ...

    • You should be sure that your Type fileds are well defined in order to let the form_start helper set the right form-enctype.

    • The form_enctype(formView) helper is deprecated since Symfony 2.3.

    0 讨论(0)
提交回复
热议问题