Sha256: 5237de936d3edb14c4a729127d7dada32f1880e9ec7c983eb61fc2350220f596

Contents?: true

Size: 951 Bytes

Versions: 3

Compression:

Stored size: 951 Bytes

Contents

class StandardFormBuilder < AbstractFormBuilder
  
  # text_field_block(:username, { :class => 'long' }, { :class => 'wide-label' })
  # text_area_block(:username, { :class => 'long' }, { :class => 'wide-label' })
  # password_field_block(:username, { :class => 'long' }, { :class => 'wide-label' })
  # file_field_block(:username, { :class => 'long' }, { :class => 'wide-label' })
  self.field_types.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]
      @template.content_block_tag(:p, :concat => false) do
        html =  label(field, label_options)
        html << #{field_type}(field, options)
      end
    end
    EOF
  end

  # submit_block("Update")
  def submit_block(caption)
    @template.content_block_tag(:p, :concat => false) do
      @template.submit_tag(caption)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinatra_more-0.0.11 lib/sinatra_more/markup_plugin/form_builder/standard_form_builder.rb
sinatra_more-0.0.10 lib/sinatra_more/markup_plugin/form_builder/standard_form_builder.rb
sinatra_more-0.0.9 lib/sinatra_more/markup_plugin/form_builder/standard_form_builder.rb