Class Field

Description

Field object that corresponds to one field in a SQL table row.

A number of fields would normally be held together in a DBRow, with the DBRow object controlling the updating to the SQL database.

Typical usage is through inheritance, see example for DBRow.

  1.      $f new TextField("name""Name");

Located in /inc/formslib/field.php (line 36)


	
			
Direct descendents
Class Description
CheckBox a checkbox object
ChoiceList a choice list field from which a select, list of hrefs etc can be built
CommentField a non-SQL active field (for the information of the user, not the database)
DateTimeField a textfield designed for date-time data
DateField textfield form widget designed to contain dates
DummyField a dummy field does not exist in the database but stores data in the form
JoinMatrix Similar to JoinData, but presents the options in a matrix not a list
JoinData an object that manages data related by an SQL JOIN but pretends to be a single form field.
ReferenceField a non-editable reference object to explain a table entry
TextField The textfield widget primitive
TimeField a textfield widget designed to handle time date
Variable Summary
array $attr
string $changed
integer $DEBUG
string $defaultValue
string $description
tristate $editable
string $errorclass
string $hidden
string $isValid
string $isValidTest
string $longname
string $name
string $namebase
string $oob_status
string $ovalue
boolean $required
boolean $sqlHidden
boolean $useNullValues
string $value
string $valueCleaner
Method Summary
Field Field (string $name, [string $longname = ''], [string $description = ''])
void display ()
void displayInTable ([integer $cols = 3])
mixed getValue ()
void hidden ()
boolean isValid ()
void log (string $logstring, [integer $priority = 10])
string selectable ()
string selectedValue ()
void set (string $value)
void setattr (array $attrs)
void setEditable ([boolean $editable = 1])
void setNamebase ([ $namebase = ''], boolean $editable)
string sqlSetStr ([string $name = ''], [boolean $force = false])
string text_dump ()
boolean update (array $data)
void __clone ()
Variables
array $attr = array() (line 68)
  • var: display attributes
string $changed = 0 (line 56)
  • var: the value of this field has changed
integer $DEBUG = 0 (line 86)
  • var: debug log level
string $defaultValue = '' (line 50)
  • var: default value of the field
string $description (line 42)
  • var: description for the field in the mouse-over
string $duplicateName (line 52)
  • var: duplicate the value of this field (when hidden) in a hidden field with this name
tristate $editable = -1 (line 54)
  • var: this field is editable
string $errorclass = 'error' (line 70)
  • var: CSS class to be used for marking fields with errors
string $hidden (line 58)
  • var: the field is a hidden widget

Redefined in descendants as:
string $isValid = 1 (line 60)
  • var: the data contained by the field is valid
string $isValidTest = 'isset' (line 74)
  • var: function to call to check that the data is valid
string $longname (line 40)
  • var: label for the field in the display
string $name (line 38)
  • var: name of this field
string $namebase (line 72)
  • var: prepended to the name of the field in the html id and hence in the data array
string $notifyIdChange = 0 (line 62)
  • var: if the ID changes, then notify descendents
string $oob_errorMessage = '' (line 84)
  • var: error message from this field or its descendents
string $oob_status = STATUS_NOOP (line 82)
  • var: status code of the descendents of this field (out-of-band data reporting)
string $ovalue (line 48)
  • var: previous value of this field
boolean $required = 0 (line 44)
  • var: field is required
boolean $requiredTwoStage = 0 (line 80)
  • var: this field requires two-stage sync
boolean $sqlHidden = 0 (line 78)
  • var: don't generate an SQL name=value representation for this field
tristate $suppressValidation = -1 (line 64)
  • var: don't to validation on this field
boolean $useNullValues = 0 (line 66)
  • var: permit NULL values in this field
string $value (line 46)
  • var: value of this field
string $valueCleaner = null (line 76)
  • var: function to call to clean the data string before testing if valid
Methods
Constructor Field (line 95)

Create a new generic field object, designed to be superclasses

Field Field (string $name, [string $longname = ''], [string $description = ''])
  • string $name: the name of the field (db name, and html field name
  • string $longname: long name to be used in the label of the field in display
  • string $description: used in the html title or longdesc for the field
displayInTable (line 255)

render this form widget in an html table

  • abstract:
void displayInTable ([integer $cols = 3])
  • integer $cols: number of columns to be included in table (padding cols will be added)

Redefined in descendants as:
getValue (line 281)

Obtain the value of the field, taking account of default values

  • return: field value
mixed getValue ()

Redefined in descendants as:
hidden (line 244)

html representation of this field as a "hidden" form widget

void hidden ()

Redefined in descendants as:
isValid (line 161)

Check the validity of the current data value.

This also checks the validity of the data even if the data is not newly-entered. Returns true if the specified validity tests are passed:

  • is the field required to be filled in && is it filled in?
  • is there a validity test && is the data valid?

  • return: is the data value valid
boolean isValid ()

Redefined in descendants as:
log (line 310)

Generic logging function

void log (string $logstring, [integer $priority = 10])
  • string $logstring: data to log
  • integer $priority: log level for this message
selectable (line 273)

return an html representation of the widget

  • return: html widget
  • abstract:
string selectable ()

Redefined in descendants as:
selectedValue (line 264)

return the current value as text and the widget as a hidden form element

  • return: current value
  • abstract:
string selectedValue ()

Redefined in descendants as:
set (line 182)

set the value of this field

without validation or checking to see whether the field has changed.

void set (string $value)
  • string $value: the new value for this field

Redefined in descendants as:
setattr (line 216)

Set display attributes for the field.

the attribute fielde are parsed differently for each different field subclass

  • access: public
void setattr (array $attrs)
  • array $attrs: attribute_name => value
setEditable (line 291)

set whether this field is editable or not

void setEditable ([boolean $editable = 1])
  • boolean $editable: new editable state

Redefined in descendants as:
setNamebase (line 300)

set the namebase for the data storage in the html form

void setNamebase ([ $namebase = ''], boolean $editable)
  • boolean $editable: new editable state
  • $namebase

Redefined in descendants as:
sqlSetStr (line 197)

create an SQL-injection-cleansed string for db statements

Generates a string that represents this field that can be used in an SQL UPDATE or INSERT statement. i.e. "name='Stuart'".

  • return: in SQL assignable form
string sqlSetStr ([string $name = ''], [boolean $force = false])
  • string $name: optional SQL name to use to change the default
  • boolean $force: optional force the generation of the command

Redefined in descendants as:
text_dump (line 226)

Quick and dirty display of the field status

  • return: simple text representation of the class's value and attributes
string text_dump ()

Redefined in descendants as:
update (line 122)

update the value of the object with the user-supplied data in $data

$data is most probably from POST data etc.

The validity of the data is *not* checked at this stage, the object only takes the user-supplied value.

$data is an array with the data relevant to this field being in the key $this->namebase.$this->name.

For example:

  1.  $this->namebase 'person-';
  2.  $this->name     'phonenumber';

  • return: did the value of this object change?
boolean update (array $data)
  • array $data: is name => value pairs as above

Redefined in descendants as:
__clone (line 321)

PHP5 clone method

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

void __clone ()

Redefined in descendants as:

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