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
Grouped collection input #382
Grouped collection input #382
Conversation
Nice. I would just recommend that instead of checking :group_method, we could simply use :as to specify it:
And then instead of having :group_method, we would simply use :value_method and :label_method which are already the official API used by collections. |
class GroupedCollectionInput < CollectionInput | ||
def input | ||
group_label_method, label_method, value_method = detect_collection_methods | ||
@builder.send(:"grouped_collection_#{input_type}", attribute_name, collection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this input_type
here, neither send
. You can call only
@builder.grouped_collection_select(attribute_name, collection,
group_method, group_label_method, value_method, label_method,
input_options, input_html_options)
Good point, I will do that. Do you think |
We need to detect label for group collection separately from child collections because they are probably different
+1 for grouped_select |
Grouped collection input
Grouped collection input Conflicts: test/inputs_test.rb
I wanted to add grouped collection input so that you could do
f.association :category, :collection => Category.roots, :group_method => :children
. Rails hasgrouped_collection_select
alongside withcollection_select
so it should be pretty similar to existing collection input.The only thing I don't know how to deal with is how SimpleForm maps inputs to classes. Right now every input with collection option maps to select input type which maps to CollectionInput. I wish every input with group_method option map to the same select input type but also somehow map it to GroupedCollectionInput.
Do you like my idea and do you have any suggestions on the problem? Thanks.