creating a failing spec for mixing objects with arrays in a select input collection #961

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

hammady commented Jul 17, 2013

Failing spec for issue #960. It appeared that the input builder is confused when mixing model objects with other types. If objects come first, the other type is just blanked. If it comes last, its option values are incorrectly set.

Owner

justinfrench commented Apr 5, 2014

@hammady Thanks for this, and sorry it's been such a long time. I've had a look at your specs, and I believe that the bug you've raised is in fact an issue with Rails' own select helper, which I'd prefer to use rather than build our own.

Your specs show examples using the :collection option, which leads us down the code path of using Formtastic::Inputs::Base::Collections#collection_from_options, which in your case would simply return the Array untouched. #collection_from_options is used by #collection, which is used by Formtastic::Inputs::SelectInput#select_html, which passes your untouched collection Array over to builder.select(), which is a standard Rails form helper.

I believe you'd need to patch Rails instead of Formtastic to make this work. Another option or work-around might be to create some kind of FormOptionSeparator object that responds to the right method names that Rails is expecting in the select() helper.

I'm going to close this for now as well as #960 with the same comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment