summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-03-22 06:52:09 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-03-22 06:52:09 +0000
commita87f724ad529e71386352f0b38d52185ba7f052c (patch)
tree96fb5f5b1d12103183cf47cb972ce3fc6520b72e /app
parent0bbc2d50a796653691a812edcf0ea4f27e29b456 (diff)
downloadredmine-a87f724ad529e71386352f0b38d52185ba7f052c.tar.gz
redmine-a87f724ad529e71386352f0b38d52185ba7f052c.zip
Merged r21488 and r21489 to 4.2-stable (#36593).
git-svn-id: https://svn.redmine.org/redmine/branches/4.2-stable@21491 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 2845db235..2d2ff5748 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -968,6 +968,17 @@ class Project < ActiveRecord::Base
end
end
+ # Overrides Redmine::Acts::Customizable::InstanceMethods#validate_custom_field_values
+ # so that custom values that are not editable are not validated (eg. a custom field that
+ # is marked as required should not trigger a validation error if the user is not allowed
+ # to edit this field).
+ def validate_custom_field_values
+ user = User.current
+ if new_record? || custom_field_values_changed?
+ editable_custom_field_values(user).each(&:validate_value)
+ end
+ end
+
# Returns the custom_field_values that can be edited by the given user
def editable_custom_field_values(user=nil)
visible_custom_field_values(user)