Module: Waves::Helpers::Form
- 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.
Instance Method Summary collapse
-
#properties(&block) ⇒ Object
This method really is a place-holder for common wrappers around groups of properties.
-
#property(options) ⇒ Object
Invokes the form view for the
type
given in the option.
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.
23 24 25 26 27 |
# File 'lib/helpers/form.rb', line 23 def properties(&block) div.properties do yield end end |
#property(options) ⇒ Object
Invokes the form view for the type
given in the option.
30 31 32 |
# File 'lib/helpers/form.rb', line 30 def property( ) self << view( :form, [:type], ) end |