From 3cea91884b28b52df4e38f2ba88c00b65071a81f Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 25 Oct 2008 04:11:30 +0000 Subject: Bug 291433: Ability to have custom fields whose visibility depends on the values of other fields Patch By Max Kanat-Alexander r=bbaetz, a=mkanat --- Bugzilla/Field/Choice.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Bugzilla/Field') diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index dbdfea1a3..4da644f1d 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -186,6 +186,10 @@ sub remove_from_db { ThrowUserError("fieldvalue_still_has_bugs", { field => $self->field, value => $self }); } + if (my @vis_fields = @{ $self->controls_visibility_of_fields }) { + ThrowUserError('fieldvalue_is_controller', + { value => $self, fields => [map($_->name, @vis_fields)] }); + } $self->SUPER::remove_from_db(); } @@ -248,6 +252,14 @@ sub is_static { return 0; } +sub controls_visibility_of_fields { + my $self = shift; + $self->{controls_visibility_of_fields} ||= Bugzilla::Field->match( + { visibility_field_id => $self->field->id, + visibility_value_id => $self->id }); + return $self->{controls_visibility_of_fields}; +} + ############ # Mutators # ############ -- cgit v1.2.3-24-g4f1b