Module: Waves::Helpers::Form

Included in:
Extended
Defined in:
lib/helpers/form.rb

Overview

Form helpers are used in generating forms. Since Markaby already provides Ruby methods for basic form generation, the focus of this helper is on providing templates to handle things that go beyond the basics. You must define a form template directory with templates for each type of form element you wish to use. The names of the template should match the type option provided in the property method.

For example, this code:

property :name => 'blog.title', :type => :text, :value => @blog.title

will invoke the text form view (the template in templates/form/text.mab), passing in the name (‘blog.title’) and the value (@blog.title) as instance variables.

These helpers work best with Markaby, but may work for other Renderers.

Instance Method Summary collapse

Instance Method Details

#properties(&block) ⇒ Object

This method really is a place-holder for common wrappers around groups of properties. You will usually want to override this. As is, it simply places a DIV element with class ‘properties’ around the block.



26
27
28
29
30
# File 'lib/helpers/form.rb', line 26

def properties(&block)
  div.properties do
    yield
  end
end

#property(options) ⇒ Object

Invokes the form view for the type given in the option.



33
34
35
# File 'lib/helpers/form.rb', line 33

def property( options )
  self << view( :form, options[:type], options )
end