Module: Mack::View::FormBuilder::ClassMethods

Defined in:
lib/mack/view/form_builder.rb

Overview

included

Instance Method Summary collapse

Instance Method Details

#partial(element_name, partial) ⇒ Object

Defines the path to a partial to use for a form element.

Example:

class MySiteFormBuilder
  include Mack::View::FormBuilder

  partial :password_field, 'form_partials/password_field'
end


129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/mack/view/form_builder.rb', line 129

def partial(element_name, partial)
  element_name = element_name.to_sym
  if element_name == :form_start || element_name == :form_end
    define_method(element_name) do 
      self.view.render(:partial, partial)
    end
  else
    define_method(element_name) do |*args|
      if element_name == :all
        val = element(*args)
      else
        val = element(element_name, *args)
      end
      self.view.render(:partial, partial, :locals => {:form_element => val})
    end
  end
end