calebhearth / formulaic

Simplify form filling with Capybara
MIT License
552 stars 29 forks source link

Add additional I18n label fallbacks #67

Closed seanpdoyle closed 7 years ago

seanpdoyle commented 7 years ago

Prior to this commit, Formulaic assumed that all labels would be declared as part of simple_form configuration.

This commit extends the list of possible internationalization keys that Formulaic will look up, based on existing Rails conventions.

calebhearth commented 7 years ago

From the README:

Formulaic is currently tied to simple_form translations and field structure. If you pass a string for the attribute, we’ll try to fill the input that relates to that label. We would be happy to work with you to add support for other form builders.

Also this section: https://github.com/thoughtbot/formulaic#assumptions


The yardstick for Formulaic for me has always been "If simple_form generated it (without some custom input), Formulaic should fill it". It's an opinionated tool that builds on my opinion that Rails' form helpers are better suited as building blocks to more robust tools like simple form.

For example, labels and inputs aren't generated together since they're separate helpers in Rails. Because of that, it's easiest to use with simple form and possible to use with other tools (by passing strings). There is prior art to turning down things based on Formulaic (and me, and thoughtbot) being opinionated.

I'm slightly fuzzier on this part, but if I recall correctly Rails' helpers also don't generate inputs that Formulaic can fill for some data types, especially dates / times. Adding the ability to correctly find those inputs would not allow them to be filled at any rate.