0

After installation of the new Symfony2.6 along with the integrated Bootstrao form theme. I now have an issue when rendering Money fields.

A picture it probably easier than trying to describe it.

Issue with Money Field

The code used to render the field from with-in the Bootstrap_3_layout.html.twig looks like this:

//Bootstrap_3_layout.html.twig
{% block money_widget -%}
    <div class="input-group">
        {% set prepend = '{{' == money_pattern[0:2] %}
        {% if not prepend %}
            <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
        {% endif %}
        {{- block('form_widget_simple') -}}
        {% if prepend %}
            <span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
        {% endif %}
    </div>
{%- endblock money_widget %}

And the rendered Html looks like this:

<div class="input-group">
   <input type="text" id="cost" name="product[cost]" required="required" class="form-control">
   <span class="input-group-addon">{{ tag_start }}€{{ tag_end }} </span>
</div>

Before the upgrade to 2.6 the fields worked perfectly fine.

I've checked that the Intl extension is enabled in php.ini and in in config.yml I have these settings:

//Config.yml
framework:
    translator:      { fallback: "%locale%" }
    default_locale:  "%locale%"

//Php.ini
[intl]
intl.default_locale = en_utf8

//forms/ProductType.php
->add('cost', 'money', array(
'currency' => 'EUR',
'label' => 'Cost',
))

//views/show.html.twig
{{ form_row(form.cost)}}
Doug
  • 1,850
  • 23
  • 50
  • try adding a money pattern in your twig render? – Derick F Dec 19 '14 at 21:36
  • I took your exact code and tried it out in my project and it worked perfectly, the only difference is the input-group div where my span was rendered before the input, thus my belief is that you prepend is somehow different. – Derick F Dec 20 '14 at 09:37
  • Can't see any sign of any difference there, I'll check "simple_widget" later it's possible I've done something to it. Thank you for your help so far. – Doug Dec 20 '14 at 10:12
  • Still can't find the cause. Just disabled the bootstrap file in my config.yml and it works fine again so thinking I might be best off just commenting out the money widget from the theme for the time being. – Doug Dec 21 '14 at 08:19

1 Answers1

1

Gah, I've found the cause. Something between the Symfony version of Bootstrap was conflicting with BrainCrafted/BootstrapBundle.

I know the addition of the Bootstrap theme to Symfony2.6 is probably meant to nullify the need for external bundles for using Bootstrap, yet there are parts of the Braincrafted bundle I would still like to use. So the way I've managed to get this to work properly for my need's is by removing:

//Braincrafter/BootstrapBundle/Resources/config/services/form.xml
    <service id="braincrafted_bootstrap.form.type.money" class="%braincrafted_bootstrap.form.type.money.class%">
        <tag name="form.type" alias="money" />
    </service>
Doug
  • 1,850
  • 23
  • 50