From 7072d6a673f9a05b688d07e05980b7932c7abbe6 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Fri, 14 May 2010 07:25:05 -0700 Subject: Bug 561296: A fix allowing updating a field value's name when it is the default value r=LpSolit, a=LpSolit --- Bugzilla/Field/Choice.pm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Bugzilla/Field') diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index 95fb4bf82..e4cb4406a 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -61,7 +61,7 @@ use constant VALIDATORS => { value => \&_check_value, sortkey => \&_check_sortkey, visibility_value_id => \&_check_visibility_value_id, - isactive => \&Bugzilla::Object::check_boolean, + isactive => \&_check_isactive, }; use constant CLASS_MAP => { @@ -216,6 +216,25 @@ sub set_visibility_value { # Validators # ############## +sub _check_isactive { + my ($invocant, $value) = @_; + $value = Bugzilla::Object::check_boolean($invocant, $value); + if (!$value and ref $invocant) { + if ($invocant->is_default) { + my $field = $invocant->field; + ThrowUserError('fieldvalue_is_default', + { value => $invocant, field => $field, + param_name => $invocant->DEFAULT_MAP->{$field->name} + }); + } + if ($invocant->is_static) { + ThrowUserError('fieldvalue_not_deletable', + { value => $invocant, field => $invocant->field }); + } + } + return $value; +} + sub _check_value { my ($invocant, $value) = @_; -- cgit v1.2.3-24-g4f1b