aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorAdam Niedzielski <adam.niedzielski@goodylabs.com>2013-09-06 13:41:24 +0200
committerAdam Niedzielski <adam.niedzielski@goodylabs.com>2013-09-09 07:59:07 +0200
commite18f045b6518d555f14ac84f39aa4177ea51185d (patch)
tree9b9d89819106384f4656084bb32efd04a2aae1f0 /actionview/lib/action_view/helpers/form_helper.rb
parent638adfc447609f498ac1461886507110704f4638 (diff)
downloadrails-e18f045b6518d555f14ac84f39aa4177ea51185d.tar.gz
rails-e18f045b6518d555f14ac84f39aa4177ea51185d.tar.bz2
rails-e18f045b6518d555f14ac84f39aa4177ea51185d.zip
form_for - fix :namespace and :as options clash
:as option should not overwrite :namespace option when generating html id attribute of the form element. id should be prefixed by specified namespace even if :as option is present Add test case showing the issue and code fixing it
Diffstat (limited to 'actionview/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index 8a4830d887..ead7871fc5 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -442,10 +442,11 @@ module ActionView
object = convert_to_model(object)
as = options[:as]
+ namespace = options[:namespace]
action, method = object.respond_to?(:persisted?) && object.persisted? ? [:edit, :patch] : [:new, :post]
options[:html].reverse_merge!(
class: as ? "#{action}_#{as}" : dom_class(object, action),
- id: as ? "#{action}_#{as}" : [options[:namespace], dom_id(object, action)].compact.join("_").presence,
+ id: (as ? [namespace, action, as] : [namespace, dom_id(object, action)]).compact.join("_").presence,
method: method
)