Class: Formidable::FormBuilder

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

Constant Summary collapse

HTML_FIELDS =
%w(date_field date_select email_field file_field number_field
password_field search_field telephone_field text_area
text_field url_field)

Instance Method Summary collapse

Instance Method Details

#button(*args) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/formidable/form_builder.rb', line 76

def button(*args)
  options = args.extract_options!
  if options[:disable_on_click]
    (:div, class: 'actions') do
      super(*args, disabled: options[:disabled], data: { disable_with: options[:disable_on_click] })
    end
  else
     :div, super(*args, disabled: options[:disabled]), class: 'actions'
  end
end

#check_box(name, *args) ⇒ Object



53
54
55
56
57
# File 'lib/formidable/form_builder.rb', line 53

def check_box(name, *args)
  (:div, class: ['field', 'checkbox', custom_class(*args)].reject(&:blank?).join(' ')) do
    [super, ' ', custom_label(name, *args) ,error(name), hint(*args)].inject(&:+)
  end
end

#collection_check_boxes(name, *args) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/formidable/form_builder.rb', line 35

def collection_check_boxes(name, *args)
  (:div, class: 'field checkbox-buttons') do
    custom_label(name, *args) +
    (:div, class: 'input') do
      [super,  ' ',  error(name),  hint(*args)].inject(&:+)
    end
  end
end

#collection_radio_buttons(name, *args) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/formidable/form_builder.rb', line 44

def collection_radio_buttons(name, *args)
  (:div, class: 'field radio-buttons') do
    custom_label(name, *args) +
    (:div, class: 'input') do
      [super, ' ', error(name), hint(*args)].inject(&:+)
    end
  end
end

#collection_select(name, *args) ⇒ Object



29
30
31
32
33
# File 'lib/formidable/form_builder.rb', line 29

def collection_select(name, *args)
  (:div, class: ['field', 'select', custom_class(*args)].reject(&:blank?).join(' ')) do
    [custom_label(name, *args), super, ' ',  error(name), hint(*args)].inject(&:+)
  end
end

#radio_button(name, *args) ⇒ Object



59
60
61
62
63
# File 'lib/formidable/form_builder.rb', line 59

def radio_button(name, *args)
  (:div, class: 'field radio') do
    [super, ' ', custom_label(name, *args) ,error(name), hint(*args)].inject(&:+)
  end
end

#select(name, *args) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/formidable/form_builder.rb', line 20

def select(name, *args)
  (:div, class: ['field', 'select', custom_class(*args)].reject(&:blank?).join(' ')) do
    custom_label(name, *args) +
    (:div, class: 'input') do
      [super, ' ',  error(name), hint(*args)].inject(&:+)
    end
  end
end

#submit(*args) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/formidable/form_builder.rb', line 65

def submit(*args)
  options = args.extract_options!
  if options[:disable_on_click]
    (:div, class: 'actions') do
      super(*args, disabled: options[:disabled], data: { disable_with: options[:disable_on_click] })
    end
  else
     :div, super(*args, disabled: options[:disabled]), class: 'actions'
  end
end