summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-01-11 12:26:44 +0000
committerGo MAEDA <maeda@farend.jp>2021-01-11 12:26:44 +0000
commit354d30df31bbc783aa512ce603ee53d604b0c64d (patch)
tree0c2db08c5141dd019a22f22cb917ec969e0ed54b /app
parentd64a2934ff6d6dd1f540bd8f025b7a41ec8eecfb (diff)
downloadredmine-354d30df31bbc783aa512ce603ee53d604b0c64d.tar.gz
redmine-354d30df31bbc783aa512ce603ee53d604b0c64d.zip
Add class 'error' to custom fields with validation errors (#32764, #34580).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20710 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/custom_fields_helper.rb3
-rw-r--r--app/models/custom_field_value.rb2
-rw-r--r--app/models/issue.rb2
3 files changed, 4 insertions, 3 deletions
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 41b20c46a..2845c8673 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -111,7 +111,8 @@ module CustomFieldsHelper
content_tag(
"label", content +
(required ? " <span class=\"required\">*</span>".html_safe : ""),
- :for => for_tag_id)
+ :for => for_tag_id,
+ :class => custom_value.customized && custom_value.customized.errors[custom_value.custom_field.name].present? ? 'error' : nil)
end
# Return custom field tag with its label tag
diff --git a/app/models/custom_field_value.rb b/app/models/custom_field_value.rb
index c670b30bd..d906454a6 100644
--- a/app/models/custom_field_value.rb
+++ b/app/models/custom_field_value.rb
@@ -65,7 +65,7 @@ class CustomFieldValue
def validate_value
custom_field.validate_custom_value(self).each do |message|
- customized.errors.add(:base, custom_field.name + ' ' + message)
+ customized.errors.add(custom_field.name, message)
end
end
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 2c6437311..1c0554f98 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -805,7 +805,7 @@ class Issue < ActiveRecord::Base
attribute = attribute.to_i
v = custom_field_values.detect {|v| v.custom_field_id == attribute}
if v && Array(v.value).detect(&:present?).nil?
- errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
+ errors.add(v.custom_field.name, l('activerecord.errors.messages.blank'))
end
else
if respond_to?(attribute) && send(attribute).blank? && !disabled_core_fields.include?(attribute)