Class: Trestle::Form::Builder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Trestle::Form::Builder
show all
- Defined in:
- lib/trestle/form/builder.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/trestle/form/builder.rb', line 32
def method_missing(name, *args, &block)
if field = self.class.fields[name]
field.new(self, @template, *args, &block).render
else
super
end
end
|
Class Method Details
.register(name, field) ⇒ Object
22
23
24
25
|
# File 'lib/trestle/form/builder.rb', line 22
def self.register(name, field)
rename_existing_helper_method(name)
self.fields[name] = field
end
|
Instance Method Details
#errors(name) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/trestle/form/builder.rb', line 14
def errors(name)
if object.respond_to?(:errors) && object.errors.respond_to?(:[])
object.errors[name].to_a
else
[]
end
end
|