Class: BootstrapFormHelper::FormControls

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

Instance Method Summary collapse

Instance Method Details

#check_box(attribute, text, options = {}, checked_value = 1, unchecked_value = 0) ⇒ Object



148
149
150
151
152
153
154
155
156
157
# File 'lib/bootstrap_form_helper/form_builder.rb', line 148

def check_box(attribute, text, options = {}, checked_value = 1, unchecked_value = 0)
  klasses = 'checkbox'
  klasses += ' inline' if options.delete :inline

  @template.label_tag nil, class: klasses do
    @template.concat super(attribute, options, checked_value, unchecked_value)
    @template.concat text
    yield if block_given?
  end
end

#radio_button(attribute, value, text = nil, options = {}) ⇒ Object



159
160
161
162
163
164
165
166
167
168
# File 'lib/bootstrap_form_helper/form_builder.rb', line 159

def radio_button(attribute, value, text = nil, options = {})
  klasses = 'radio'
  klasses += ' inline' if options.delete :inline

  @template.label_tag nil, class: klasses do
    @template.concat super(attribute, value, options)
    @template.concat text || value.to_s.humanize.titleize
    yield if block_given?
  end
end