Sha256: 46b3060f94fa6b995ceecfc8268fdc9e9812b1c5d2ab1178431cfefe5e0149d7

Contents?: true

Size: 1.68 KB

Versions: 23

Compression:

Stored size: 1.68 KB

Contents

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

module Padrino
  module Helpers
    module FormBuilder
      class StandardFormBuilder < AbstractFormBuilder
        ##
        # 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={})
            if options[:caption]
              options = options.dup
              label_options = { :caption => options.delete(:caption) }.update(label_options)
            end
            field_html = label(field, label_options)
            field_html << #{field_type}(field, options)
            @template.content_tag(:p, field_html)
          end
          EOF
        end

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

        def image_submit_block(source, options={})
          submit_html = self.image_submit(source, options)
          @template.content_tag(:p, submit_html)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
padrino-helpers-0.16.0.pre3 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.16.0.pre2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.15.3 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.15.2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.15.1 lib/padrino-helpers/form_builder/standard_form_builder.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/padrino-helpers-0.13.3.4/lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.15.0 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.4 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.3 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.13.3.4 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.1.1 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.1 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.0.2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.0.1 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.0 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.0.rc2 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.14.0.rc1 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.13.3.3 lib/padrino-helpers/form_builder/standard_form_builder.rb
padrino-helpers-0.13.3.2 lib/padrino-helpers/form_builder/standard_form_builder.rb