Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

AbstractField Class Reference
[Basic Fields]

Inheritance diagram for AbstractField:

Field AbstractListField ButtonField CheckboxField CollectionField DateField EditorField HiddenField LabelField RadioField TextareaField TextField TimeField UploadField List of all members.

Detailed Description

Abstract field class.

Most (read: all) fields inherit from this.

Author:
Scott Peshak, Zach Smith

Definition at line 9 of file abstract-field.inc.php.

Public Member Functions

 __construct ($name, Form &$parentForm, array $attribs=array())
 Constructor.
 __get ($name)
 Magic getter.
 __set ($name, $value)
 Magic setter.
 validate ()
 Validate the feild's contents.
 getTitle ()
 hasError ()
 Return the status of the field after running validate.
 forceError ()
 Force the field to have an error.
 getSqlImpl ()
 Get the SQL for this field.
 setData ($value)
 Set data.
 getData ()
 Get the data value.
 getJs ()
 Get any JavaScript needed for the field This is for JavaScript that will be common for all instances of this field type.
 getCss ()
 Get any CSS needed for the field.
 addAttributes (array $attr)
 Add more attributes.

Public Attributes

 $name = ''
 Name of the Field, must correspond with a database column name if sync is used.
 $definition = ''

Protected Member Functions

 parseExtras (array $data)
 Parse the extra values.
 extrasAsAttributes ()
 Convert the extra attributes array as an HTML attribute string.
 setDataFromRequest ()
 Set the form's data from the $_POST array.
 convertSpecialRegex ($regExp, $defaultError)
 Convert a special regex identifier (eg: 'number', 'float') into a real regex.

Static Protected Member Functions

 assertAttributeIsArray (&$value)
 Assert that an attribute value is an array.
 assertAttributeIsObject ($type, &$value)
 Assert that an attribute value is an instance of an object type.

Protected Attributes

 $title = ''
 Display title for the form.
 $value = ''
 Data value.
 $attribs = array()
 Array of extra attributes.
 $required = false
 Boolean flag, if true then the field will not validate until a vaild value is input.
 $regExp = ''
 Optional regular expression that is use to validate the input.
 $errorMessage = ''
 Error message to display if an error is encountered.
 $hasError = false
 Boolean flag set after validation.
 $parentForm = ''
 Reference to the parent Form object.


Member Function Documentation

AbstractField::__construct name,
Form &$  parentForm,
array $  attribs = array()
 

Constructor.

Parameters:
$name Field name
$parentForm Form object that the field belongs to.
$attribs Array of extra attributes. Any non special key values will simply be output in the HTML of the field. Special keys include:
  • value Sets a default value for the field
  • required If true then the field is "required" (will not validate with an empty value)
  • errorMessage Message to display if an error is encountered during validation.
  • regExp Regular expression to use for validation. The special values of number & float can be used. Inheirited fields may define additional special keys as needed.

Implements Field.

Reimplemented in AbstractListField, AutoCompleteField, CheckboxField, CityStateZipField, CollectionField, ConditionalField, DateField, DateTimeField, EditorField, EmailField, GenderField, IpAddressField, NameField, PasswordChangeField, PhoneNumberField, SSNField, TimeField, and UsStateField.

Definition at line 35 of file abstract-field.inc.php.

References $attribs, hasError(), and parseExtras().

AbstractField::__get name  ) 
 

Magic getter.

Parameters:
$name Name of member that is being attempted

Definition at line 55 of file abstract-field.inc.php.

AbstractField::__set name,
value
 

Magic setter.

Parameters:
$name Name of the member to set
$value Value to set

Reimplemented in AbstractListField, ButtonField, CollectionField, ConditionalField, EditorField, PasswordChangeField, and UploadField.

Definition at line 70 of file abstract-field.inc.php.

References $name, and setData().

Referenced by parseExtras().

AbstractField::addAttributes array $  attr  ) 
 

Add more attributes.

Parameters:
$attr array of attributes

Definition at line 183 of file abstract-field.inc.php.

AbstractField::assertAttributeIsArray &$  value  )  [static, protected]
 

Assert that an attribute value is an array.

Parameters:
$value Value to check

Definition at line 270 of file abstract-field.inc.php.

AbstractField::assertAttributeIsObject type,
&$  value
[static, protected]
 

Assert that an attribute value is an instance of an object type.

Parameters:
$type Object type to check for.
$value Value to check.

Definition at line 281 of file abstract-field.inc.php.

References $value.

AbstractField::convertSpecialRegex regExp,
defaultError
[protected]
 

Convert a special regex identifier (eg: 'number', 'float') into a real regex.

Also generates an error message appropirate for the resulting regex.

Parameters:
$regExp RegEx string to convert (if it not a special identifier it is passed back out unchanged)
$defaultError Default error message to use if no conversion takes place
Returns:
Array with keys 'regexp' and 'message'

Definition at line 232 of file abstract-field.inc.php.

References $regExp.

AbstractField::extrasAsAttributes  )  [protected]
 

Convert the extra attributes array as an HTML attribute string.

Returns:
attribute string

Definition at line 206 of file abstract-field.inc.php.

Referenced by TextareaField::drawInput(), TextField::drawInput(), SelectField::drawInput(), RadioField::drawInput(), PasswordField::drawInput(), MultiSelectField::drawInput(), CheckboxField::drawInput(), and ButtonField::drawInput().

AbstractField::forceError  ) 
 

Force the field to have an error.

This is most useful for forcing all fields in a collection to display as an error.

Implements Field.

Definition at line 131 of file abstract-field.inc.php.

References hasError().

AbstractField::getCss  ) 
 

Get any CSS needed for the field.

Implements Field.

Reimplemented in CollectionField, and PasswordChangeField.

Definition at line 174 of file abstract-field.inc.php.

AbstractField::getData  ) 
 

Get the data value.

Implements Field.

Reimplemented in ButtonField, CollectionField, DateTimeField, IpAddressField, MultiSelectField, PasswordField, PasswordChangeField, PhoneNumberField, and SSNField.

Definition at line 157 of file abstract-field.inc.php.

AbstractField::getJs  ) 
 

Get any JavaScript needed for the field This is for JavaScript that will be common for all instances of this field type.

Implements Field.

Reimplemented in CollectionField, ConditionalField, and PasswordChangeField.

Definition at line 166 of file abstract-field.inc.php.

AbstractField::getSqlImpl  ) 
 

Get the SQL for this field.

Returns:
SQL string

Implements Field.

Reimplemented in ButtonField, CheckboxListField, CityStateZipField, CollectionField, DateTimeField, IpAddressField, LabelField, NameField, PasswordField, PasswordChangeField, PhoneNumberField, and SSNField.

Definition at line 140 of file abstract-field.inc.php.

AbstractField::getTitle  ) 
 

Definition at line 107 of file abstract-field.inc.php.

AbstractField::hasError  ) 
 

Return the status of the field after running validate.

Returns:
Boolean true if there is an error, false otherwise

Implements Field.

Reimplemented in ButtonField, and CollectionField.

Definition at line 119 of file abstract-field.inc.php.

References hasError().

Referenced by __construct(), forceError(), hasError(), and validate().

AbstractField::parseExtras array $  data  )  [protected]
 

Parse the extra values.

Parameters:
$attribs array of extra attributes.

Definition at line 193 of file abstract-field.inc.php.

References __set().

Referenced by __construct().

AbstractField::setData value  ) 
 

Set data.

Parameters:
$value Value to set

Implements Field.

Reimplemented in CheckboxListField, DateTimeField, IpAddressField, MultiSelectField, PhoneNumberField, and SSNField.

Definition at line 149 of file abstract-field.inc.php.

Referenced by __set().

AbstractField::setDataFromRequest  )  [protected]
 

Set the form's data from the $_POST array.

Reimplemented in CollectionField, DateField, LabelField, and TimeField.

Definition at line 218 of file abstract-field.inc.php.

Referenced by validate().

AbstractField::validate  ) 
 

Validate the feild's contents.

Implements Field.

Reimplemented in ButtonField, CheckboxField, CollectionField, IpAddressField, PasswordChangeField, SSNField, and UploadField.

Definition at line 85 of file abstract-field.inc.php.

References hasError(), and setDataFromRequest().


Member Data Documentation

AbstractField::$attribs = array() [protected]
 

Array of extra attributes.

Definition at line 14 of file abstract-field.inc.php.

Referenced by __construct().

AbstractField::$definition = ''
 

Definition at line 20 of file abstract-field.inc.php.

AbstractField::$errorMessage = '' [protected]
 

Error message to display if an error is encountered.

Definition at line 17 of file abstract-field.inc.php.

AbstractField::$hasError = false [protected]
 

Boolean flag set after validation.

Definition at line 18 of file abstract-field.inc.php.

AbstractField::$name = ''
 

Name of the Field, must correspond with a database column name if sync is used.

Definition at line 11 of file abstract-field.inc.php.

Referenced by __set().

AbstractField::$parentForm = '' [protected]
 

Reference to the parent Form object.

Definition at line 19 of file abstract-field.inc.php.

AbstractField::$regExp = '' [protected]
 

Optional regular expression that is use to validate the input.

Definition at line 16 of file abstract-field.inc.php.

Referenced by convertSpecialRegex().

AbstractField::$required = false [protected]
 

Boolean flag, if true then the field will not validate until a vaild value is input.

Definition at line 15 of file abstract-field.inc.php.

AbstractField::$title = '' [protected]
 

Display title for the form.

Definition at line 12 of file abstract-field.inc.php.

AbstractField::$value = '' [protected]
 

Data value.

Definition at line 13 of file abstract-field.inc.php.

Referenced by assertAttributeIsObject().


The documentation for this class was generated from the following file:
Generated on Fri Oct 27 12:26:40 2006 for BaseJumper by doxygen 1.3.9.1