问题
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