Class EntryField

Description

Individual fields used for data entry / viewing.

This object is not really intended to be used directly. The more normal interface is to instantiate an EntryForm and then issue calls to DataEntryLine() and other EntryForm methods.

Understanding the operation of this class (and possibly auditing the source code, particularly EntryField::Render) will however convey valuable understanding of some of the more esoteric features.

  • todo:

    This class doesn't really provide a huge amount of utility between construct and render, but there must be good things possible there. Perhaps one EntryField is created and used repeatedly as a template (e.g.). That might be useful to support... Why is this a Class anyway? Maybe we should have just done half a dozen functions (one per major field type) and just used those... Maybe we should build a base class for this and extend it to make EntryField in a better way.

    EntryField is only useful at present if you desperately want to use it's simple field interface, but want to intimately control the layout (or parts of the layout), otherwise you should be using EntryForm as the main class.

Located in /DataEntry.php (line 38)


	
			
Variable Summary
 string $attributes
 string $current
 string $rendered
Method Summary
 static string BuildOptionList ( $qry, [string $current = ''], [string $location = 'options'], [array $parameters = false])
 EntryField EntryField (text $intype, text $inname, [text $attributes = ""], [text $current_value = ""])
 void new_lookup (array $attributes)
 text Render ()
Variables
string $attributes (line 69)

An array of key value pairs

  • access: public
string $current (line 63)

The current value

  • access: public
string $rendered (line 75)

Once it actually is...

  • access: public
Methods
static BuildOptionList (line 294)

Build an option list from the query.

  • return: Select box HTML
static string BuildOptionList ( $qry, [string $current = ''], [string $location = 'options'], [array $parameters = false])
  • string $current: Default selection of drop down box (optional)
  • string $location: for debugging purposes
  • array $parameters: an array further parameters, including 'maxwidth' => 20 to set a maximum width
  • $qry
Constructor EntryField (line 137)

Initialise an EntryField, used for data entry.

The following types of fields are possible:

  • select - Will display a select list of the keys/values in $attributes where the key starts with an underscore. The key will have the '_' removed before being used as the key in the list. All the $attributes with keys not beginning with '_' will be used in the normal manner as HTML attributes within the <select ...> tag.
  • lookup - Will display a select list of values from the database. If $attributes defines a '_sql' attibute then that will be used to make the list, otherwise the database values will be from the 'codes' table as in "SELECT code_id, code_value FROM codes WHERE code_type = '_type' ORDER BY code_seq, code_id" using the value of $attributes['_type'] as the code_type.
  • date - Will be a text field, expecting a date value which might be javascript validated at some point in the future.
  • checkbox - Will display a checkbox for an on-off value.
  • textarea - Will display an HTML textarea.
  • file - Will display a file browse / enter field.
  • button - Will display a button field.
  • password - Password entry. This will display entered data as asterisks.

The $attributes array is useful to set specific HTML attributes within the HTML tag used for the entry field however $attribute keys named starting with an underscore ('_') affect the field operation rather than the HTML. For the 'select' field type, these are simply used as the keys / values for the selection (with the '_' removed), but other cases are more complex:

  • _help - While this will be ignored by the EntryField::Render() method the _help should be assigned (or will be assigned the same value as the 'title' attribute) and will (depending on the data-entry line format in force) be displayed as help for the field by the EntryForm::DataEntryLine() method.
  • _sql - When used in a 'lookup' field this controls the SQL to return keys/values for the list. The actual SQL should return two columns, the first will be used for the key and the second for the displayed value.
  • _type - When used in a 'lookup' field this defines the codes type used.
  • _null - When used in a 'lookup' field this will control the description for an option using a '' key value which will precede the list of values from the database.
  • _zero - When used in a 'lookup' field this will control the description for an option using a '0' key value which will precede the list of values from the database.
  • _label - When used in a 'radio' or 'checkbox' field this will wrap the field with an HTML label tag as <label ...><input field...>$attributes['_label']</label>
  • -

EntryField EntryField (text $intype, text $inname, [text $attributes = ""], [text $current_value = ""])
  • text $intype: The type of field: select | lookup | date | checkbox | textarea | file | button | password (anything else is dealt with as "text")
  • text $inname: The name of the field.
  • text $attributes: An associative array of extra attributes to be applied to the field. Optional, but generally important. Some $attribute keys have special meaning, while others are simply added as HTML attributes to the field.
  • text $current_value: The current value to use to initialise the field. Optional.
new_lookup (line 283)

Function called indirectly when a new EntryField of type 'lookup' is created.

void new_lookup (array $attributes)
  • array $attributes: The attributes array that was passed in to the new EntryField() constructor.
Render (line 162)

Render an EntryField into HTML

text Render ()

Documentation generated on Wed, 04 Jul 2012 07:06:13 +0000 by phpDocumentor 1.4.3