Class: Malline::FormBuilder
- Inherits:
-
Object
- Object
- Malline::FormBuilder
- Defined in:
- lib/malline/form_builder.rb
Overview
Capture form elements directly from FormBuilder, so that there is no need to specially render any elements. In other words, with our own FormBuilder-wrapper we can do this: form_for :comment, Comment.new, :url => edit_url do |f| f.text_field :name end instead of .. self << f.text_field(:name)
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ FormBuilder
constructor
Wrap the Rails FormBuilder in @builder.
-
#method_missing(*args, &block) ⇒ Object
Render every f.foo -method to view, unless we aren’t using Malline template now.
Constructor Details
#initialize(*args, &block) ⇒ FormBuilder
Wrap the Rails FormBuilder in @builder
30 31 32 33 |
# File 'lib/malline/form_builder.rb', line 30 def initialize *args, &block @view = eval('self', args.last) @builder = ::ActionView::Helpers::FormBuilder.new(*args, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
Render every f.foo -method to view, unless we aren’t using Malline template now
36 37 38 39 40 41 42 |
# File 'lib/malline/form_builder.rb', line 36 def method_missing *args, &block if @view && @view.is_malline? @view << @builder.send(*args, &block) else @builder.send(*args, &block) end end |