Module: Tramway::Utils::Field

Included in:
Tailwinds::Form::Builder
Defined in:
lib/tramway/utils/field.rb

Overview

Provides dynamic field rendering

Instance Method Summary collapse

Instance Method Details

#tramway_field(field_data, attribute, **options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tramway/utils/field.rb', line 7

def tramway_field(field_data, attribute, **options, &)
  input_type = field_type(field_data)
  input_name = field_name input_type
  input_options = field_options(field_data).merge(options)

  case input_type.to_sym
  when :select, :multiselect
    collection = input_options.delete(:collection)

    public_send(input_name, attribute, collection, **input_options, &)
  else
    public_send(input_name, attribute, **input_options, &)
  end
end