Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

i18n for buttons #847

Closed
sevenseacat opened this Issue · 4 comments

3 participants

@sevenseacat

Using Formtastic 2.2.0.

I know the readme says it should be possible to configure i18n for buttons using:

en:
  formtastic:
    actions:
      create: 'My text'

However this simply doesn't seem to work. Neither does nesting the create key under a model name.

If I use a named key, eg create_foo and then reference it in my view f.action :submit, label: :create_foo it works, but no other method seems to.

@yabawock
Collaborator

Did you enable enhanced I18n lookups in the initializer?

Formtastic::FormBuilder.i18n_lookups_by_default = true
@justinfrench

There's some test coverage around this in spec/actions/generic_action_spec.rb

This namespace seems right:

en:
  formtastic:
    actions:

Inside there, these are the keys we're referencing:

  • if it's form for an object AND the object responds to either persisted? or new_record?
    • use update if it's persisted?
    • otherwise use create
  • otherwise use the method (submit in your example, but there's also cancel and reset)

So I think the full list of keys is

  • create
  • update
  • cancel
  • reset
  • submit

I would view the "submit" key as a fallback, used usually when the form's object doesn't smell like an ActiveModel and we can't figure out if it should be a create or update. Try setting an update and submit key and let me know how you go.

I'm leaving this open because we obviously need some documentation around this.

@justinfrench
Owner

Added documentation in 0a81d19, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.