Symfony form week picker

只愿长相守 提交于 2020-01-16 04:43:12

问题


I would like the equivalent of this:

<input type="week" ..>

with Symfony Form.

I try this:

{{ form_widget(form.date, {'attr': {'type': 'week'}}) }}

but it doesn't work.


回答1:


You can use a form theme. Supposing your form is named foo and your field is named bar, add this to a theme (inside your template or in a dedicated theme file):

{% block _foo_bar_widget %}
    {%- set type = 'week' -%}
    {{- block('date_widget') -}}
{% endblock %}


来源:https://stackoverflow.com/questions/39287340/symfony-form-week-picker

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!