diff options
-rw-r--r-- | actionpack/lib/action_view/helpers/active_record_helper.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb index 4f7d66d8f7..a2b5a8b004 100644 --- a/actionpack/lib/action_view/helpers/active_record_helper.rb +++ b/actionpack/lib/action_view/helpers/active_record_helper.rb @@ -51,12 +51,15 @@ module ActionView # </form> 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 + + options[:action] ||= record.new_record? ? "create" : "update" + action = url_for(:action => options[:action]) + + submit_value = options[:submit_value] || options[: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}) + + %(<form action="#{action}" method="post">#{id_field}) + all_input_tags(record, record_name, options) + %(<input type="submit" value="#{submit_value}" /></form>) end |