symfony - How to fix these form theming problems in Symfony2? -
i have multiple questions forms
first question, how wrap input div (with classes) in form builder?
so want wrap submit input :
->add('submit', 'submit', array( 'attr' => array( 'class' => 'btn btn-success' ), ))
to result :
<div class="col-sm-offset-2 col-sm-10"> <input type="submit" class="btn btn-success"/> </div>
second question, how set template form via form builder?
is there method in wrong example? or not?
public function buildform(formbuilderinterface $builder, array $options) { $builder ->settemplate('::vertical-form.html.twig') ->add(...) }
last question, how add class form element in custom form template?
i grab piece of code form_div_layout.html.twig , add class (9th line) form element. doesn't work, can't see element in view!
{% block form_start %} {% spaceless %} {% set method = method|upper %} {% if method in ["get", "post"] %} {% set form_method = method %} {% else %} {% set form_method = "post" %} {% endif %} <form class="form-horizontal" role="form" name="{{ form.vars.name }}" method="{{ form_method|lower }}" action="{{ action }}"{% attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}> {% if form_method != method %} <input type="hidden" name="_method" value="{{ method }}" /> {% endif %} {% endspaceless %} {% endblock form_start %}
in views, i've piece of code render form:
{% form_theme form '::custom-form.html.twig' %} {{ form(form_name) }}
maybe should copy form_div_layout.html.twig file template , tweak need?
thanks in advance help!
in opinion in case should create submit button manually in template (not form class)
i don't know solution looks this.
you should copy file content. read this: http://symfony.com/doc/current/cookbook/form/form_customization.html
Comments
Post a Comment