Skip to content

Instantly share code, notes, and snippets.

@carlosipe
Created June 20, 2013 21:59
Show Gist options
  • Select an option

  • Save carlosipe/5827086 to your computer and use it in GitHub Desktop.

Select an option

Save carlosipe/5827086 to your computer and use it in GitHub Desktop.
form_tag padrino
def form_tag(url, options={}, &block)
desired_method = options[:method].to_s
options.delete(:method) unless desired_method =~ /get|post/i
options.reverse_merge!(:method => 'post', :action => url)
options[:enctype] = 'multipart/form-data' if options.delete(:multipart)
options['accept-charset'] ||= 'UTF-8'
inner_form_html = hidden_form_method_field(desired_method)
inner_form_html << csrf_token_field unless desired_method =~ /get/i
inner_form_html << mark_safe(capture_html(&block))
concat_content content_tag(:form, inner_form_html, options)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment