Class: PhantomForms::FormBuilders::ValidateFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
lib/phantom_forms/form_builders/validate_form_builder.rb

Constant Summary collapse

FORM_HELPERS =
%w{text_field password_field text_area file_field
number_field email_field telephone_field phone_field url_field
select collection_select date_select time_select datetime_select}

Instance Method Summary collapse

Constructor Details

#initializeValidateFormBuilder

Returns a new instance of ValidateFormBuilder.



11
12
13
14
15
16
17
18
# File 'lib/phantom_forms/form_builders/validate_form_builder.rb', line 11

def initialize(*)
  super
  @help_tag, @help_css = if options.fetch(:help, '').to_sym == :block
    [:p, 'help-block']
  else
    [:span, 'help-inline']
  end
end

Instance Method Details

#check_box(name, *args) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/phantom_forms/form_builders/validate_form_builder.rb', line 42

def check_box(name, *args)
  options = args.extract_options!.symbolize_keys!
   :div, class: "control-group#{(' error' if object.errors[name].any?)}"  do
    (:div, class: 'controls') do
      args << options.except(:label, :help)
      html = super(name, *args) + ' ' + options[:label]
      label(name, html, class: 'checkbox')
    end
  end
end