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

Unsupported field types #39

Closed
bbenezech opened this issue Dec 3, 2015 · 2 comments
Closed

Unsupported field types #39

bbenezech opened this issue Dec 3, 2015 · 2 comments
Assignees

Comments

@bbenezech
Copy link
Contributor

Hello again,

Simple form doesn't support all field types.
For example jsonb columns will raise

ActionView::Template::Error (No input found for jsonb):
    14:           </div>
    15:
    16:         <% else %>
    17:           <%= form.input name, label: name %>
    18:         <% end %>
    19:       <% end %>
    20:     </div>
  simple_form (3.2.0) lib/simple_form/form_builder.rb:574:in `find_mapping'
  simple_form (3.2.0) lib/simple_form/form_builder.rb:503:in `find_input'
  simple_form (3.2.0) lib/simple_form/form_builder.rb:113:in `input'
  rails_db (1.0) app/views/rails_db/tables/_edit.html.erb:17:in `block (2 levels) in ___sers_ben__rvm_gems_ruby_______gems_rails_db_____app_views_rails_db_tables__edit_html_erb___3087035280528385302_70164055306820'

The way you handle it is your call. I guess I would default to text.
Not sure how.

Catching around form.input name, label: name and retrying with as: :text looks dirty, maybe you can try to toy around SimpleForm API to see if they expose smtg than can help you in find_mapping.

Unless you want to go with user-faced config hooks, but I sure wouldn't!

@igorkasyanchuk
Copy link
Owner

@bbenezech please add me in skype - "igorkasyanchuk" if you want.
I really like what you are making and found issues you have found and your solutions.
I think we can discuss them and plan fixes together if you want.

@bbenezech bbenezech self-assigned this Dec 14, 2015
@bbenezech
Copy link
Contributor Author

SimpleForm fallbacks on custom types named after field's type.

For ex. a jsonb field would need an app/inputs/jsonb_input.rb file:

class JsonbInput < SimpleForm::Inputs::TextInput; end

It works fine with a limited hassle.

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

2 participants