Class: ActiveElement::Components::Util::FormFieldMapping
- Inherits:
-
Object
- Object
- ActiveElement::Components::Util::FormFieldMapping
- Includes:
- EmailFields, PhoneFields, SecretFields
- Defined in:
- lib/active_element/components/util/form_field_mapping.rb
Overview
Normalizes Form ‘fields` parameter from various supported input formats.
Constant Summary
Constants included from EmailFields
Constants included from PhoneFields
Constants included from SecretFields
Instance Method Summary collapse
- #fields_with_types_and_options ⇒ Object
-
#initialize(record:, fields:, controller:, i18n:, search: false) ⇒ FormFieldMapping
constructor
A new instance of FormFieldMapping.
Methods included from EmailFields
Methods included from PhoneFields
Methods included from SecretFields
Constructor Details
#initialize(record:, fields:, controller:, i18n:, search: false) ⇒ FormFieldMapping
Returns a new instance of FormFieldMapping.
12 13 14 15 16 17 18 |
# File 'lib/active_element/components/util/form_field_mapping.rb', line 12 def initialize(record:, fields:, controller:, i18n:, search: false) @controller = controller @record = record || default_record @fields = fields @i18n = i18n @search = search end |
Instance Method Details
#fields_with_types_and_options ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_element/components/util/form_field_mapping.rb', line 20 def compiled_fields = fields.map do |field| next (field) unless field.is_a?(Array) next (field) if normalized_field?(field) next (field) if (field) next field_with_type(field) if field_name_with_type?(field) raise_unrecognized_field_format(field) end fields_with_default_label(compiled_fields) end |