Sha256: 4a747e0d6ab215f04e2cb2d762c762a42149fb49ba86ef9f914b1f2bfba608e8

Contents?: true

Size: 546 Bytes

Versions: 5

Compression:

Stored size: 546 Bytes

Contents

class FormView < Garterbelt::View
  requires :method => :get
  
  def initialize(options, &block)
    super
    self.method = method.to_s.downcase
  end
  
  def content
    form form_options do
      if legal_method != method
        input :type => 'hidden', :name => "_method", :value => method
      end  
        
      block.call if block
    end
  end
  
  def form_options
    options.merge(:method => legal_method)
  end
  
  def legal_method
    if ['get', 'post'].include?( method )
      method
    else
      'post'
    end 
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
garterbelt-0.0.9 spec/integration/templates/form.rb
garterbelt-0.0.8 spec/integration/templates/form.rb
garterbelt-0.0.7 spec/integration/templates/form.rb
garterbelt-0.0.6 spec/integration/templates/form.rb
garterbelt-0.0.5 spec/integration/templates/form.rb