5.7.33. Bugzilla::Field::Choice

5.7.33.1. NAME

Bugzilla::Field::Choice - A legal value for a <select>-type field.

5.7.33.2. SYNOPSIS

my $field = new Bugzilla::Field({name => 'bug_status'});

my $choice = new Bugzilla::Field::Choice->type($field)->new(1);

my $choices = Bugzilla::Field::Choice->type($field)->new_from_list([1,2,3]);
my $choices = Bugzilla::Field::Choice->type($field)->get_all();
my $choices = Bugzilla::Field::Choice->type($field->match({ sortkey => 10 });

5.7.33.3. DESCRIPTION

This is an implementation of Bugzilla::Object, but with a twist. You can't call any class methods (such as new, create, etc.) directly on Bugzilla::Field::Choice itself. Instead, you have to call Bugzilla::Field::Choice->type($field) to get the class you're going to instantiate, and then you call the methods on that.

We do that because each field has its own database table for its values, so each value type needs its own class.

See the SYNOPSIS for examples of how this works.

This class implements Bugzilla::Field::ChoiceInterface, and so all methods of that class are also available here.

5.7.33.4. METHODS

Class Factory

In object-oriented design, a "class factory" is a method that picks and returns the right class for you, based on an argument that you pass.

type

Takes a single argument, which is either the name of a field from the fielddefs table, or a Bugzilla::Field object representing a field.

Returns an appropriate subclass of Bugzilla::Field::Choice that you can now call class methods on (like new, create, match, etc.)

NOTE: YOU CANNOT CALL CLASS METHODS ON Bugzilla::Field::Choice. You must call type to get a class you can call methods on.

Mutators

This class implements mutators for all of the settable accessors in Bugzilla::Field::ChoiceInterface.

5.7.33.5. Methods in need of POD

create

remove_from_db

set_is_active

set_sortkey

set_name

update

set_visibility_value


This documentation undoubtedly has bugs; if you find some, please file them here.