Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should have a helper to create update_elements hash #76

Open
kakra opened this issue Nov 14, 2016 · 0 comments
Open

Should have a helper to create update_elements hash #76

kakra opened this issue Nov 14, 2016 · 0 comments

Comments

@kakra
Copy link

kakra commented Nov 14, 2016

I'm using the following application helper that's handy when creating the :update_elements option:

def autofill form, *fields
  fields.inject({}) {|hash,field| hash.merge! field => "##{form.object_name}_#{field.to_s}" }
end

Use like this:

f.autocomplete_field :brand_name, autocomplete_brand_name_products_path,
  update_elements: autofill(f, :slogan, :extra1, :extra2)

This can be used as a companion method to the model method for generating custom json when using semantic forms.

Maybe this could be incorporated into this gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant