How to override Symfony form MoneyType input as type=“number”?

前端 未结 4 877
天命终不由人
天命终不由人 2021-01-18 09:54

The Symfony MoneyType Field renders as input type=\"text\" which allows a user to type whatever they want into the field.

How can I override this to ren

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 10:38

    You can customise how the MoneyType is rendered.

    {% extends 'form_div_layout.html.twig' %}
    
    {% block money_widget %}
        {%- set type = type|default('number') -%}
        {{ parent() }}
    {% endblock %}
    

    Sources:

    http://symfony.com/doc/current/form/form_customization.html#method-2-inside-a-separate-template https://github.com/symfony/symfony/issues/22937#issuecomment-304609466

提交回复
热议问题