Class: Markaby::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/reststop.rb

Instance Method Summary collapse

Instance Method Details

#form(*args, &block) ⇒ Object

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



448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/reststop.rb', line 448

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