Class: TailwindForm::FormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
lib/tailwind_form/form_builder.rb

Instance Method Summary collapse

Instance Method Details

#form_group(name, classes = 'form__group', field_type = :text_field) ⇒ Object



24
25
26
27
28
29
# File 'lib/tailwind_form/form_builder.rb', line 24

def form_group(name, classes = 'form__group', field_type = :text_field)
  function_name = "tailwind_#{field_type}"
  @template. :div, class: classes do
    tailwind_label_field(name) + send(function_name, name)
  end
end

#tailwind_label_field(name) ⇒ Object



5
6
7
8
# File 'lib/tailwind_form/form_builder.rb', line 5

def tailwind_label_field(name)
  field_options = { class: 'form__label' }
  label(name, field_options)
end

#tailwind_text_area(name) ⇒ Object



17
18
19
20
21
22
# File 'lib/tailwind_form/form_builder.rb', line 17

def tailwind_text_area(name)
  field_options = { class: 'form__input' }
  @template. :div, class: 'form__inputGroup' do
    text_area(name, field_options)
  end
end

#tailwind_text_field(name) ⇒ Object



10
11
12
13
14
15
# File 'lib/tailwind_form/form_builder.rb', line 10

def tailwind_text_field(name)
  field_options = { class: 'form__input' }
  @template. :div, class: 'form__inputGroup' do
    text_field(name, field_options)
  end
end