diff options
author | Robin Houston <robin@lenny.robin> | 2011-09-08 01:21:08 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-09-08 01:21:08 +0100 |
commit | 723505344edc7af189b23ffcf9cd033f19727436 (patch) | |
tree | c8ee4a5821d4cff9592a83c09ffd1a8a38b1b2c6 /app/helpers/application_helper.rb | |
parent | 0b35486809a9a5ef8ba371549b05390682427392 (diff) |
Make HTML ids unique even with multiple locales
In situations where a block of HTML is generated for each enabled locale,
we need to include the locale name in generated ids otherwise the id will
not be unique within the document, resulting in invalid HTML.
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d12238582..a0f16dfaf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -105,8 +105,12 @@ module ApplicationHelper method_name.sub(/\?$/, "") end - def form_tag_id(object_name, method_name) - return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}" + def form_tag_id(object_name, method_name, locale=nil) + if locale.nil? + return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}" + else + return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}__#{locale.to_s}" + end end end |