Symfony / Twig: How to change money_pattern?

By default Symfony adds a currency sign to the input field. I would like to add a currency sign.

Here is the snippet that I must rewrite:

{% block money_widget -%}    
   {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
{%- endblock money_widget %}

      

My current quick and dirty solution:

{% block money_widget -%}
   {% set money_pattern = '{{ widget }} €' %}
   {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
{%- endblock money_widget %}

      

  • How do I get the currency sign in this branch-block (instead of €

    ?
  • Where to rewrite money_pattern before?

Thanks in advance! B.

+3


source to share


2 answers


The only thing that worked for me was to set it when the helper was called.

{{ form_row(form.value, { 'money_pattern': '{{ widget }} $' }) }}

      



In theory, you can also specify it in the form builder, but that didn't work for me. Possibly a structural error.

+1


source


You don't have to do anything. According to Symfony2 documentation ( here ):

Depending on the currency - the currency symbol can be displayed before or after the text input field.



Just set the money field parameter. According to the same documentation page, that should be a 3 letter ISO 4217 code. So it probably felt wrong to you because you typed in the wrong code.

0


source







All Articles