formtastic-bootstrap
formtastic-bootstrap copied to clipboard
as: :select unrecognized input on non-model form when using PostgreSQL
EDIT: turns out it had nothing with moving to postgresql --- I ran bundle update and that pushed formtastic to 3.0.0, which is what broke everything. See https://github.com/mjbellantoni/formtastic-bootstrap/issues/109#issuecomment-56828388 for solution
I had a form that was working perfectly when I was using SQLite. I moved to PostgreSQL and for some reason this broke formtastic-bootstrap's ability to recognize :select as an input type.
Formtastic::UnknownInputError - "Unable to find input class for select"
To reproduce this error try the following:
$ rails new select-error-app --database=postgresql
$ rails g scaffold Post title:string body:text
$ rake db:create
$ rake db:migrate
$ rake db:setup
Add the following to the top of the auto-generated app/views/posts/index.html.erb file:
<%= semantic_form_for 'filter_form' do |f| %>
<%= f.input :test, as: :select, collection: {"item 1" => 1, "Item 2" => 2, "Item 3" => 3} %>
<%= f.actions %>
<% end %>
Add the required styles and gem files etc for formtastic-bootstrap
Now run rails server
$ rake rails server
Navigate to http://localhost:3000 in your web browser. You should now get the same error I'm getting.
This is a model-less form, which is supported according to the formtastic documentation as long as you specify an "as:" for each input.
As far as I can tell this will not throw the same error if you use SQLite.
What could be causing this error?
What versions of rails, formtastic, formtastic-bootstrap are you using?
Using bootstrap-sass 3.2.0.2
Using formtastic 3.0.0
Using formtastic-bootstrap 3.0.0
Using rails 4.1.5
formtastic-bootstrap 3.0 actually only support formtastic 2.x. Try downgrading to formtastic 2.3.1 and see if it resolves the issue?
That worked, though it made all the bootstrap styles on my form elements stop working :/
Yeah it looks like once I did that none of my text inputs are using the new bootstrap styles. Is there a way to fix this and still use the bootstrap 3.x styles?
UPDATE: so it looks like I have to force formtastic-bootstrap to be 3.0.0, but keep formtastic at 2.3.1 and then everything works.
Yes, that's the expected combination. I will update the gemspec today to show the f-b 3 doesn't support f 3.
Are there any plans to support formtastic 3? ActiveAdmin has moved into requiring formtastic 3, so there will be no way to use latest activeadmin and formtastic-bootstrap...
I'm happy to accept Pull Requests to make us compatible with Formtastic 3. I'm not sufficiently familiar with the changes in F3 to know if we can be compatible with both Formtastic 2.3 and 3.0 at the same time – mostly this is a matter of picking sensible version numbers.
UPDATE: this is fixed with this commit: https://github.com/mjbellantoni/formtastic-bootstrap/commit/18fab411ee597a1543b4499b4c69d65e019c1fdd
Formtastic is still v 3.0.0 as my gem previously stated, but sourcing from github brings that important commit which fixes this situation.
Thanks for the update. I'll try to make time for a release soon.