Class: Wallaby::FormBuilder

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (protected)



18
19
20
21
22
23
24
25
# File 'lib/forms/wallaby/form_builder.rb', line 18

def method_missing(method, *args, &block)
  if @template.respond_to? method
    self.class.delegate method, to: :@template
    @template.public_send method, *args, &block
  else
    super
  end
end

Instance Method Details

#error_class(field_name) ⇒ Object



2
3
4
# File 'lib/forms/wallaby/form_builder.rb', line 2

def error_class(field_name)
  'has-error' if has_error? field_name
end

#error_messages(field_name) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/forms/wallaby/form_builder.rb', line 6

def error_messages(field_name)
  errors = Array object.errors[ field_name ]
  return if errors.blank?

   :ul, class: 'text-danger' do
    errors.each do |message|
      concat  :li, (:small, raw(message))
    end
  end
end