Symfony形式的星期选择器 [英] Symfony form week picker

查看:89
本文介绍了Symfony形式的星期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望与此相当:

I would like the equivalent of this:

<input type="week" ..>

with Symfony Form。

with Symfony Form.

我试试这个:

I try this:

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

但无效。

but it doesn't work.

推荐答案

您可以使用表单主题。假设您的表单名为 foo ,并且您的字段名为 bar ,请将其添加到主题中(在您的模板中或一个专门的主题文件):

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 %}

这篇关于Symfony形式的星期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆