class Markaby::Builder

Public Instance Methods

form(*args, &block) click to toggle source

Modifies Markaby's 'form' generator so that if a 'method' parameter is supplied, a hidden '_method' input is automatically added.

# File lib/reststop.rb, line 450
def form(*args, &block)
  options = args[0] if args && args[0] && args[0].kind_of?(Hash)
  inside = capture &block
  
  if options && options.has_key?(:method)
    inside = input(:type => 'hidden', :name => '_method', :value => options[:method]) +
      inside
    if options[:method].to_s === 'put' || options[:method].to_s == 'delete'
      options[:method] = 'post'
    end
  end
  
  tag!(:form, options || args[0]) {inside}
end