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

SimpleForm displays single line input fields for translated attributes #109

Closed
jmuheim opened this issue Nov 1, 2017 · 7 comments
Closed

Comments

@jmuheim
Copy link

jmuheim commented Nov 1, 2017

I have a text field :content.

Usually, SimpleForm correctly displays a textarea for it:

= f.input :content

When translating the field using Mobility, it displays a single line input!

If you need a demo Rails application, I can set up one for you.

@pwim
Copy link
Collaborator

pwim commented Nov 2, 2017

@jmuheim To work around this, use SimpleForm's as argument

= f.input :content, as: :text

@shioyama
Copy link
Owner

shioyama commented Nov 2, 2017

Thanks @pwim, I was going to look to see if something like that was possible.

@jmuheim Mobility can't really fix this kind of problem, since ultimately translated attributes are virtual attributes, not table columns. There are only going to be situation-specific solutions like the one above.

However, I will add the workaround above to the wiki.

@shioyama shioyama closed this as completed Nov 2, 2017
@shioyama
Copy link
Owner

shioyama commented Nov 2, 2017

Added to the wiki page on using Mobiliity with forms.

@pwim
Copy link
Collaborator

pwim commented Nov 2, 2017

@shioyama SimpleForm uses type_for_attribute to determine which input type to create. I suppose we could overwrite this method to delegate to the backend, but that might open another can of worms. I don't see this as something Globalize needs to support, but if someone was to want to step up and create a PR to handle it, I think it would be worth considering.

@shioyama
Copy link
Owner

shioyama commented Nov 2, 2017

Globalize Mobility 😉

@pwim
Copy link
Collaborator

pwim commented Nov 2, 2017

Good catch. For the record, this isn't something that Globalize handles either.

@shioyama
Copy link
Owner

shioyama commented Nov 3, 2017

I suppose we could overwrite this method to delegate to the backend, but that might open another can of worms.

That's an idea, but I'd suggest maybe having another gem like mobility-simple_form or something with a plugin to do this would be best. But if the solution in this case is as simple as as: :text, I'm not sure it's really worth the trouble.

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

3 participants