aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/active_record_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/active_record_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index eee8b6b970..4f7d66d8f7 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -52,12 +52,13 @@ module ActionView
def form(record_name, options = {})
record = instance_eval("@#{record_name}")
action = url_for(:action => options[:action] || (record.new_record? ? "create" : "update"))
+ submit_value = options[:submit_value] || action.gsub(/[^\w]/, '').capitalize
+
id_field = record.new_record? ? "" : InstanceTag.new(record_name, "id", self).to_input_field_tag("hidden")
-
- "<form action='#{action}' method='post'>" +
- id_field + all_input_tags(record, record_name, options) +
- "<input type='submit' value='#{action.gsub(/[^A-Za-z]/, "").capitalize}' />" +
- "</form>"
+
+ %(<form action="#{action}" method="POST">#{id_field}) +
+ all_input_tags(record, record_name, options) +
+ %(<input type="submit" value="#{submit_value}" /></form>)
end
# Returns a string containing the error message attached to the +method+ on the +object+, if one exists.