symfony - How can I change symfony2 form fields default options globally? -
is there way change default options form fields globally in symfony2?
more specifically, want change render of all datetime fields use single_text
instead of default choice
widget.
can done? or need implement custom type , set default in there, example birthdate
type?
i prefer option leads minimal changes in codebase.
you have define form theme.
it's easy , requires little bit coding time. first of all, have know block customize; in case, can like
{% block my_data_widget %} {% spaceless %} {% if type defined , type == 'date' %} // customization {% else %} // don't know ... {% endif %} {% endspaceless %} {% endblock form_widget_simple %}
now have defined snippet of code, can use main template (or whatever use form views) in way
{% form_theme form 'yourbundle:form:mydatawidget' %}
last not least important, have place form theme resources/views
folder. in example, path resources/views/form/mydatawidget
update
did tried with
{% set type = type|default('single_text') %}
or that?
Comments
Post a Comment