stouset / twitter_bootstrap_form_for

A Rails FormBuilder DSL for generating Twitter Bootstrap forms
https://github.com/stouset/twitter_bootstrap_form_for
MIT License
409 stars 110 forks source link

add a price_field method #69

Closed hdgarrood closed 11 years ago

hdgarrood commented 11 years ago

Assuming we're in a twitter_bootstrap_form_for block with user as the block variable:

the attached code makes this:

= user.price_field :balance

equivalent to this:

= user.text_field :balance, :add_on => :prepend do
  %span.add-on= t('number.currency.format.unit').html_safe
hron84 commented 11 years ago

make the currency unit sign configurable and detect prepend/append automatically (i think there is a activesupport thing). first is more important, latter is can ignored if i can suggest this to the helper manually

hdgarrood commented 11 years ago

The currency unit sign is configurable -- it looks at the current locale's number.currency.format.unit.

hron84 commented 11 years ago

@hdgarrood you misunderstood me. In a multi-currency setup, i18n dependency is can be a problem if user wants to see prices in EUR but in HU or ES locale.

As a default behavior, taking currency sign from I18n module is a good idea, but the way to customizing this would be useful.

hdgarrood commented 11 years ago

Oh, yeah, I see.

I'm actually starting to wonder if this functionality should be in twitter_bootstrap_form_for at all. This PR has a really tiny amount of code, and I've just realised that it only really satisfies my requirement; it should only be in this library if it were to satisfy many people's requirements, or if it made doing this kind of thing significantly easier.

Since it does neither of those, I'm going to close it.