summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-05-01 15:21:42 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-05-01 15:21:42 -0400
commit521eae01be1ca3f69b47b3170a0548c3268f4a22 (patch)
tree84e15c59b334c3ce47fdd330512fec2ff074f774
parent5ce55c00ac72bc6fbdd095d7ee697cfa35ea8cc4 (diff)
Make the form submit helpers use <button>, which can be styled better
-rw-r--r--app/views/layouts/application.html.erb2
-rw-r--r--config/initializers/form_improvements.rb31
2 files changed, 32 insertions, 1 deletions
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 28ec6f7..1b83e53 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -51,7 +51,7 @@
<% end %>
<%= form_tag("/search", method: :get, :id => "search") do %><div>
<%= text_field_tag(:query, params[:query], type: :search) %>
- <button type="submit">Search</button>
+ <%= submit_tag "Search" %>
</div><% end %>
</div>
</div>
diff --git a/config/initializers/form_improvements.rb b/config/initializers/form_improvements.rb
new file mode 100644
index 0000000..c91dce8
--- /dev/null
+++ b/config/initializers/form_improvements.rb
@@ -0,0 +1,31 @@
+# -*- ruby-indent-level: 2; indent-tabs-mode: nil -*-
+module ActionView
+ module Helpers
+ module FormTagHelper
+
+ # This is modified from actionpack-4.0.2/lib/action_view/helpers/form_tag_helper.rb#submit_tag
+ def submit_tag(value = "Save changes", options = {})
+ options = options.stringify_keys
+
+ if disable_with = options.delete("disable_with")
+ message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
+ "Use 'data: { disable_with: \'Text\' }' instead."
+ ActiveSupport::Deprecation.warn message
+
+ options["data-disable-with"] = disable_with
+ end
+
+ if confirm = options.delete("confirm")
+ message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
+ "Use 'data: { confirm: \'Text\' }' instead'."
+ ActiveSupport::Deprecation.warn message
+
+ options["data-confirm"] = confirm
+ end
+
+ content_tag(:button, value, { "type" => "submit", "name" => "commit", "value" => value }.update(options))
+ end
+
+ end
+ end
+end