Topic: Using button instead of input for submit_tag

Title pretty much says it all. I am just wondering if there is any other way, short of overriding Rails default like so

def submit_tag(value = "Save changes", options = {})
  options.stringify_keys!

  if disable_with = options.delete("disable_with")
    options["onclick"] = "this.disabled=true;this.value='#{disable_with}';this.form.submit();#{options["onclick"]}"
  end
           
  tag :button, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
end

Re: Using button instead of input for submit_tag

We're using two span's in the button element to get some extra style benefits. Not quite semantic, but we can do a lot of cool stuff with it. Admittingly, it is a rip off of a Particle Tree Article where they show how to style buttons in varies ways.

Helper

  def button_for(name, options={})
    return content_tag(:button, content_tag(:span, content_tag(:span, name)), :class => options[:class], :type => options[:button_type])
  end

View

  <%= button_for("Log In", :button_type => "submit") %>

Re: Using button instead of input for submit_tag

Wow..thanks for sharing this Robert smile

Semantic or not, that code sure is pretty!

Re: Using button instead of input for submit_tag

UGH

I just found out my client wants to support mobile phone browsers and now my buttons are obsolete!

Somebody shoot me