Class: Primer::Alpha::MultiInput
- Includes:
- Forms::Dsl::InputMethods
- Defined in:
- app/components/primer/alpha/multi_input.rb
Overview
Multi inputs are comprised of multiple constituent fields, only one of which is visible at a given time. They are designed for situations where constituent inputs are shown or hidden based on the value of another field. For example, consider an address form. If the user chooses the USA as the country, the region input should show a list of states and US territories; if the user instead chooses Canada, the region input should show a list of Canadian provinces, etc.
Unlike everywhere else in Primer forms, constituent inputs are not directly passed a ‘name` attribute. Instead, developers pass a `name` attribute to the multi input itself. The multi input then automatically assigns each constituent input the same name. This is done so that the multi input looks like a single field from the server’s point of view. Using the address form example from earlier, this means only one value - either a US state or a Canadian provice - will be submitted to the server under the ‘region` key.
Actually, that’s not quite true. Constituent inputs are given a ‘name`, but it’s added to the input as the ‘data-name` attribute as a way to identify constituent inputs, and will not be sent to the server.
Constant Summary
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
- #initialize ⇒ Object constructor
Methods included from Forms::Dsl::InputMethods
#action_menu, #button, #check_box, #check_box_group, #fields_for, #hidden, #inputs, #multi, #radio_button_group, #select_list, #separator, #submit, #text_area, #text_field
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from Primer::AttributesHelper
#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Constructor Details
#initialize ⇒ Object
|
# File 'app/components/primer/alpha/multi_input.rb', line 43
|