From 3bb7524c1f282827331a31db3731fc2459d05186 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 6 Jun 2017 21:17:16 +0000 Subject: Merged r16574 (#25760). git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@16621 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/custom_fields_helper.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/helpers/custom_fields_helper.rb') diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 3f357ab0c..617a6123d 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -96,16 +96,23 @@ module CustomFieldsHelper # Return custom field label tag def custom_field_label_tag(name, custom_value, options={}) required = options[:required] || custom_value.custom_field.is_required? + for_tag_id = options.fetch(:for_tag_id, "#{name}_custom_field_values_#{custom_value.custom_field.id}") content = custom_field_name_tag custom_value.custom_field content_tag "label", content + (required ? " *".html_safe : ""), - :for => "#{name}_custom_field_values_#{custom_value.custom_field.id}" + :for => for_tag_id end # Return custom field tag with its label tag def custom_field_tag_with_label(name, custom_value, options={}) - custom_field_label_tag(name, custom_value, options) + custom_field_tag(name, custom_value) + tag = custom_field_tag(name, custom_value) + tag_id = nil + ids = tag.scan(/ id="(.+?)"/) + if ids.size == 1 + tag_id = ids.first.first + end + custom_field_label_tag(name, custom_value, options.merge(:for_tag_id => tag_id)) + tag end # Returns the custom field tag for when bulk editing objects -- cgit v1.2.3