Class: Tailwinds::Form::Builder
- Inherits:
-
Tramway::Views::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Tramway::Views::FormBuilder
- Tailwinds::Form::Builder
- Defined in:
- app/components/tailwinds/form/builder.rb
Overview
Provides Tailwind-styled forms :reek:InstanceVariableAssumption
Instance Attribute Summary
Attributes inherited from Tramway::Views::FormBuilder
Instance Method Summary collapse
- #file_field(attribute, **options) ⇒ Object
- #multiselect(attribute, collection, **options) ⇒ Object
- #password_field(attribute, **options) ⇒ Object
- #select(attribute, collection, **options) ⇒ Object
- #submit(action) ⇒ Object
- #text_field(attribute, **options) ⇒ Object
Instance Method Details
#file_field(attribute, **options) ⇒ Object
23 24 25 26 27 |
# File 'app/components/tailwinds/form/builder.rb', line 23 def file_field(attribute, **, &) input = super(attribute, **.merge(class: :hidden)) render(Tailwinds::Form::FileFieldComponent.new(input:, **(attribute, )), &) end |
#multiselect(attribute, collection, **options) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/components/tailwinds/form/builder.rb', line 38 def multiselect(attribute, collection, **, &) render(Tailwinds::Form::MultiselectComponent.new( input: input(:text_field), value: [:value] || [:selected] || object.public_send(attribute)&.first, collection:, **(attribute, ) ), &) end |
#password_field(attribute, **options) ⇒ Object
16 17 18 19 20 21 |
# File 'app/components/tailwinds/form/builder.rb', line 16 def password_field(attribute, **, &) render(Tailwinds::Form::TextFieldComponent.new( input: input(:password_field), **(attribute, ) ), &) end |
#select(attribute, collection, **options) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/components/tailwinds/form/builder.rb', line 29 def select(attribute, collection, **, &) render(Tailwinds::Form::SelectComponent.new( input: input(:select), value: [:selected] || object.public_send(attribute), collection: explicitly_add_blank_option(collection, ), **(attribute, ) ), &) end |
#submit(action) ⇒ Object
47 48 49 |
# File 'app/components/tailwinds/form/builder.rb', line 47 def submit(action, **, &) render(Tailwinds::Form::SubmitButtonComponent.new(action, **), &) end |
#text_field(attribute, **options) ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/components/tailwinds/form/builder.rb', line 8 def text_field(attribute, **, &) render(Tailwinds::Form::TextFieldComponent.new( input: input(:text_field), value: get_value(attribute, ), **(attribute, ) ), &) end |