Class ChoiceList

Description

a choice list field from which a select, list of hrefs etc can be built

A field class that can only take a restricted set of values, such as a radio list or a drop-down list.

This class cannot adequately represent itself and is designed to be inherited by a representation (such as RadioList or DropDownList)

Located in /inc/formslib/choicelist.php (line 37)

Field
   |
   --ChoiceList
Direct descendents
Class Description
AnchorList anchor list (<li><a href="$href">$name</a></li>) for a ChoiceList
CheckBoxTableList a table of checkboxes for different options
DropList a dropdown selection list using a ChoiceList
RadioList a radio button list based on the ChoiceList class
Variable Summary
tristate $deleted
boolean $extendable
integer $formatid
array $formatter
Method Summary
ChoiceList ChoiceList (string $name, [string $description = ''])
void append (array $a)
void connectDB (string $table, [mixed $fields = ''], [string $restriction = ''], [string $order = 'name'], [string $idfield = 'id'], [string $limit = ''], [string $join = ''], [boolean $distinct = false])
void display ()
string displayInTable ([integer $cols = 3])
string format (array $data)
void getValue ()
boolean isValid ()
void prepend (array $a)
void selectedValue ()
void set (string $value)
void setDefault ( $val)
void setFormat ()
void setValuesArray (array $list, [ $idfield = 'id'], [ $valfield = 'iv'])
string sqlSetStr ([ $name = ''], [boolean $force = false])
void text_dump ()
boolean update (array $data)
void __clone ()
Variables
tristate $deleted = false (line 47)
  • var: in filling list, include only deleted=true, deleted=false or both (true, false, NULL)
boolean $extendable = 0 (line 45)
  • var: additional items can be added to the choicelist
integer $formatid (line 43)
  • var: name of the id field for the value of the field
array $formatter (line 41)
  • var: array of OutputFormatter objects
DBChoiceList $list (line 39)
  • var: contains the DBChoiceList object which has the restricted choices

Inherited Variables

Inherited from Field

Field::$attr
Field::$changed
Field::$DEBUG
Field::$defaultValue
Field::$description
Field::$duplicateName
Field::$editable
Field::$errorclass
Field::$hidden
Field::$isValid
Field::$isValidTest
Field::$longname
Field::$name
Field::$namebase
Field::$notifyIdChange
Field::$oob_errorMessage
Field::$oob_status
Field::$ovalue
Field::$required
Field::$requiredTwoStage
Field::$sqlHidden
Field::$suppressValidation
Field::$useNullValues
Field::$value
Field::$valueCleaner
Methods
Constructor ChoiceList (line 55)

Create a new choice list

ChoiceList ChoiceList (string $name, [string $description = ''])
  • string $name: the name of the field (db name, and html field name
  • string $description: used in the html title or longdesc for the field
append (line 261)

appends a value to the dropdown list

void append (array $a)
  • array $a: see DBChoiceList for details
connectDB (line 79)

Create a DBList object within this class that is connected to the available choices in the database and will handle the actual parsing of user input etc

If php supported multiple inheritance, then $this->list would not be a member of the class, rather DBList would be multiply inherited along with Field.

void connectDB (string $table, [mixed $fields = ''], [string $restriction = ''], [string $order = 'name'], [string $idfield = 'id'], [string $limit = ''], [string $join = ''], [boolean $distinct = false])
  • string $table: the name of the DB table to query
  • mixed $fields: array or string specifying the field(s) to query
  • string $restriction: a restriction that will be applied to the query (WHERE...)
  • string $order: the order to display the results (ORDER BY...)
  • string $idfield: the name of the field that will be used to identify the selected item (value=)
  • string $limit: limits that will be applied to the query (LIMIT...)
  • string $join: any tables that should be LEFT JOINed in the query to make sense of it
  • boolean $distinct: return only DISTINCT rows (default: false)

Redefined in descendants as:
display (line 100)
void display ()

Redefinition of:
Field::display()
Generic display function

Redefined in descendants as:
displayInTable (line 142)

Display the field inside a table

  • return: a single row HTML representation of the field
string displayInTable ([integer $cols = 3])
  • integer $cols: the number of columns to include in the table (extras are padded out)

Redefinition of:
Field::displayInTable()
render this form widget in an html table

Redefined in descendants as:
format (line 130)

A test text-based format function for the object.

  • return: text-based representation
string format (array $data)
  • array $data: the data to be formatted by this object's formatter object

Redefined in descendants as:
getValue (line 285)
void getValue ()

Redefinition of:
Field::getValue()
Obtain the value of the field, taking account of default values
isValid (line 213)

Check the validity of the data.

Return TRUE iff the DBList isValid and the Field isValid. This permits two rounds of checks on the data to be performed.

  • return: the field's current value is valid?
boolean isValid ()

Redefinition of:
Field::isValid()
Check the validity of the current data value.
prepend (line 243)

prepends a value to the dropdown list

void prepend (array $a)
  • array $a: see DBChoiceList for details
selectedValue (line 162)
void selectedValue ()

Redefinition of:
Field::selectedValue()
return the current value as text and the widget as a hidden form element

Redefined in descendants as:
set (line 200)

Set the value of this field, both in the Field and in the DBList

void set (string $value)
  • string $value: value to be set

Redefinition of:
Field::set()
set the value of this field
setDefault (line 274)

set the default value for this object

void setDefault ( $val)
  • $val
setFormat (line 114)

Create a set of OutputFormatter objects to handle the display of this object.

called as: setFormat($id, $f1, $v1, $f2, $v2, ...) {

  • f1, v1 etc must be in pairs.
  • f1 is an sprintf format (see PHP manual)
  • v1 is an array of array indices that will be used to fill the fields in the sprintf format from a $data array passed to the formatter when asked to display itself

void setFormat ()
setValuesArray (line 92)

Provides a set of values for the droplist rather than filling it from a db query

cf. ChoiceList::connectDB

void setValuesArray (array $list, [ $idfield = 'id'], [ $valfield = 'iv'])
  • array $list: List of label=>value pairs
  • $idfield
  • $valfield
sqlSetStr (line 228)

Obtain the SQL data necessary for including the foreign key in the DBRow to which we belong.

trip the complex field within us to sync(), which allows us to then know our actual value (at last).

  • return: name='value' from parent class
string sqlSetStr ([ $name = ''], [boolean $force = false])
  • boolean $force: force the field to return a name=value statement even if it would prefer not to
  • $name

Redefinition of:
Field::sqlSetStr()
create an SQL-injection-cleansed string for db statements
text_dump (line 96)
void text_dump ()

Redefinition of:
Field::text_dump()
Quick and dirty display of the field status
update (line 177)

Update the value of the field and also the complex field within based on the user data.

This does *not* create new elements within the complex field (list) at this stage: that is deferred until the latest possible point for all error checking to be performed.

  • return: did the field change?
boolean update (array $data)
  • array $data: a set of name => value pairs from which the value of this field will be extracted

Redefinition of:
Field::update()
update the value of the object with the user-supplied data in $data
__clone (line 294)

PHP5 clone method

PHP5 clone statement will perform only a shallow copy of the object. Any subobjects must also be cloned

void __clone ()

Redefinition of:
Field::__clone()
PHP5 clone method

Redefined in descendants as:

Inherited Methods

Inherited From Field

Field::Field()
Field::display()
Field::displayInTable()
Field::getValue()
Field::hidden()
Field::isValid()
Field::log()
Field::selectable()
Field::selectedValue()
Field::set()
Field::setattr()
Field::setEditable()
Field::setNamebase()
Field::sqlSetStr()
Field::text_dump()
Field::update()
Field::__clone()

Documentation generated on Tue, 06 Mar 2007 10:01:04 +0000 by phpDocumentor 1.3.0