Sha256: 47e8b12d05f65e89243fbc71113941fa7853b6b987036d5a8c79625dc873f204

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

module Waves

  module Helpers

    # 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.
    # 
    
    module Form

      # 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.
      def properties(&block)
        div.properties do
          yield
        end
      end

      # Invokes the form view for the +type+ given in the option.
      def property( options )
        self << view( :form, options[:type], options )
      end


    end

  end

end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
dyoder-waves-0.8.0 lib/helpers/form.rb
waves-edge-2009.03.10.13.14 lib/helpers/form.rb
waves-stable-2009.3.10 lib/helpers/form.rb
waves-0.8.0 lib/helpers/form.rb
waves-0.8.1 lib/helpers/form.rb
waves-0.8.2 lib/helpers/form.rb