Sha256: 81cc57d0e8f646368b918edb89f230860401a901db2684983de2a60ba3e95f6f

Contents?: true

Size: 1.74 KB

Versions: 13

Compression:

Stored size: 1.74 KB

Contents

require File.dirname(__FILE__) + '/abstract_form_builder' unless defined?(AbstractFormBuilder)

module Padrino
  module Helpers
    module FormBuilder #:nodoc:
      class StandardFormBuilder < AbstractFormBuilder #:nodoc:

        ##
        # StandardFormBuilder
        # 
        #   text_field_block(:username, { :class => 'long' }, { :class => 'wide-label' })
        #   text_area_block(:summary, { :class => 'long' }, { :class => 'wide-label' })
        #   password_field_block(:password, { :class => 'long' }, { :class => 'wide-label' })
        #   file_field_block(:photo, { :class => 'long' }, { :class => 'wide-label' })
        #   check_box_block(:remember_me, { :class => 'long' }, { :class => 'wide-label' })
        #   select_block(:color, :options => ['green', 'black'])
        # 
        (self.field_types - [ :hidden_field, :radio_button ]).each do |field_type|
          class_eval <<-EOF
          def #{field_type}_block(field, options={}, label_options={})
            label_options.reverse_merge!(:caption => options.delete(:caption)) if options[:caption]
            field_html = label(field, label_options)
            field_html << #{field_type}(field, options)
            @template.content_tag(:p, field_html)
          end
          EOF
        end

        # submit_block("Update")
        def submit_block(caption, options={})
          submit_html = self.submit(caption, options)
          @template.content_tag(:p, submit_html)
        end

        # image_submit_block("submit.png")
        def image_submit_block(source, options={})
          submit_html = self.image_submit(source, options)
          @template.content_tag(:p, submit_html)
        end
      end # StandardFormBuilder
    end # FormBuilder
  end # Helpers
end # Padrino

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
padrino-helpers-0.9.6 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.9.5 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.9.4 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.9.3 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.9.2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.9.1 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.9.0 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.8.5 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.8.4 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.8.3 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.8.2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.8.1 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.8.0 lib/padrino-helpers/form_builder/standard_form_builder.rb