Class: ExpressTemplates::Components::Forms::SelectCollection
- Inherits:
-
Select
- Object
- Arbre::Component
- Base
- Configurable
- FormComponent
- Select
- ExpressTemplates::Components::Forms::SelectCollection
- Defined in:
- lib/express_templates/components/forms/select_collection.rb
Overview
Provides a form Select component based on the Rails collection_select helper.
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from FormComponent
Instance Method Summary collapse
- #collection_select_tag_args ⇒ Object
- #field_options ⇒ Object
- #html_options ⇒ Object
- #multi_field_name ⇒ Object
Methods inherited from Select
#field_name_attribute, #generate_options_from_field_values, #normalize_for_helper, #options_from_belongs_to, #options_from_has_many_through, #options_from_supplied_or_field_values, #select_helper_options, #select_options, #select_options_supplied?, #select_tag_args, #selected_value, #simple_options_with_selection, #use_supplied_options
Methods included from OptionSupport
#belongs_to_association, #has_many_through_association, #related_collection
Methods inherited from FormComponent
#field_helper_options, #field_id_attribute, #field_name, #field_name_attribute, #field_value, #label_name, #label_text, #parent_form, #resource, #resource_class, #resource_name
Methods included from Capabilities::Configurable
Methods inherited from Base
abstract_component, abstract_component?, before_build, #build, builder_method, builder_method_and_class, contains, descendants, has_attributes, inherited, #initialize, require_parent, required_parent, tag
Constructor Details
This class inherits a constructor from ExpressTemplates::Components::Base
Instance Method Details
#collection_select_tag_args ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/express_templates/components/forms/select_collection.rb', line 18 def collection_select_tag_args [ resource_name, multi_field_name, , :id, :name, , ] end |
#field_options ⇒ Object
26 27 28 |
# File 'lib/express_templates/components/forms/select_collection.rb', line 26 def {include_blank: !!input_attributes.delete(:include_blank)} end |
#html_options ⇒ Object
30 31 32 |
# File 'lib/express_templates/components/forms/select_collection.rb', line 30 def input_attributes.reject {|k,v| k.eql?(:include_blank)}.merge(multiple: config[:multiple]) end |
#multi_field_name ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/express_templates/components/forms/select_collection.rb', line 34 def multi_field_name if has_many_through_association "#{field_name.singularize}_ids" else raise "Only use select_collection for has_many :through. #{field_name} is not has_many :through" end end |