Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

as: :select unrecognized input on non-model form when using PostgreSQL #109

Open
sam0x17 opened this issue Sep 24, 2014 · 11 comments
Open

Comments

@sam0x17
Copy link

sam0x17 commented Sep 24, 2014

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 #109 (comment) 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?

@sodabrew
Copy link
Collaborator

What versions of rails, formtastic, formtastic-bootstrap are you using?

@sam0x17
Copy link
Author

sam0x17 commented Sep 24, 2014

Using bootstrap-sass 3.2.0.2
Using formtastic 3.0.0
Using formtastic-bootstrap 3.0.0
Using rails 4.1.5

@sodabrew
Copy link
Collaborator

formtastic-bootstrap 3.0 actually only support formtastic 2.x. Try downgrading to formtastic 2.3.1 and see if it resolves the issue?

@sam0x17
Copy link
Author

sam0x17 commented Sep 24, 2014

That worked, though it made all the bootstrap styles on my form elements stop working :/

@sam0x17
Copy link
Author

sam0x17 commented Sep 24, 2014

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?

@sam0x17
Copy link
Author

sam0x17 commented Sep 25, 2014

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.

@sodabrew
Copy link
Collaborator

Yes, that's the expected combination. I will update the gemspec today to show the f-b 3 doesn't support f 3.

@glampr
Copy link
Contributor

glampr commented Sep 28, 2014

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...

@sodabrew
Copy link
Collaborator

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.

@hakunin
Copy link

hakunin commented Dec 8, 2014

UPDATE: this is fixed with this commit:
18fab41

Formtastic is still v 3.0.0 as my gem previously stated, but sourcing from github brings that important commit which fixes this situation.

@sodabrew
Copy link
Collaborator

sodabrew commented Dec 8, 2014

Thanks for the update. I'll try to make time for a release soon.

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

No branches or pull requests

4 participants