I'm having a bit of difficulty styling a MoneyType form input the way I want. I want to use Bootstrap's input-group-addon class to prepend a dollar sign to the field, but what's actually happening is that two dollar signs are being rendered... one automatically generated by the MoneyType, and one that I manually wrote in my template:
Template:
<div class="form-group">
{{ form_label(form.canonicalPrice) }}
{{ form_errors(form.canonicalPrice) }}
<div class="input-group">
<span class="input-group-addon">$</span>
{{ form_widget(form.canonicalPrice, { 'attr': {'id': 'price', 'class': 'form-control'} }) }}
</div>
</div>
MoneyType definition in my form type class:
->add('canonicalPrice', MoneyType::class, array('label' => 'Price', 'currency' => 'USD'))
Screenshot:
So, is there a way for me to either:
- Hide the automatic currency label that Symfony adds with a
MoneyTypefield? Not specifying any currency defaults to a Euro rather than dollar, which isn't helpful. - Style the automatic label the way I want?
Note: I'm not using Symfony's Bootstrap form themes because I like having complete control over my templates. The fact that MoneyType fields default to showing a currency is very annoying.
