Andrew's Web Libraries (AWL)
Loading...
Searching...
No Matches
EntryField Class Reference

Public Member Functions

 __construct ( $intype, $inname, $attributes="", $current_value="")
 
 Render ()
 
 new_lookup ( $attributes)
 

Static Public Member Functions

static BuildOptionList ( $qry, $current='', $location='options', $parameters=false)
 

Public Attributes

 $fname
 
 $ftype
 
 $current
 
 $attributes
 
 $rendered
 

Detailed Description

Definition at line 38 of file DataEntry.php.

Constructor & Destructor Documentation

◆ __construct()

EntryField::__construct ( $intype,
$inname,
$attributes = "",
$current_value = "" )

#- 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>
  • -
Parameters
text$intypeThe type of field: select | lookup | date | checkbox | textarea | file | button | password (anything else is dealt with as "text")
text$innameThe name of the field.
text$attributesAn 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_valueThe current value to use to initialise the field. Optional.

Definition at line 137 of file DataEntry.php.

Member Function Documentation

◆ BuildOptionList()

static EntryField::BuildOptionList ( $qry,
$current = '',
$location = 'options',
$parameters = false )
static

Build an option list from the query.

Parameters
string$currentDefault selection of drop down box (optional)
string$locationfor debugging purposes
array$parametersan array further parameters, including 'maxwidth' => 20 to set a maximum width
Returns
string Select box HTML

Definition at line 294 of file DataEntry.php.

◆ new_lookup()

EntryField::new_lookup ( $attributes)

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

Parameters
array$attributesThe attributes array that was passed in to the new EntryField() constructor.

Definition at line 283 of file DataEntry.php.

◆ Render()

EntryField::Render ( )

Render an EntryField into HTML

See also
EntryField::EntryField(), EntryForm\DataEntryLine()
Returns
text An HTML fragment for the data-entry field.

Definition at line 162 of file DataEntry.php.

Member Data Documentation

◆ $attributes

EntryField::$attributes

Definition at line 69 of file DataEntry.php.

◆ $current

EntryField::$current

Definition at line 63 of file DataEntry.php.

◆ $fname

EntryField::$fname

Definition at line 47 of file DataEntry.php.

◆ $ftype

EntryField::$ftype

Definition at line 53 of file DataEntry.php.

◆ $rendered

EntryField::$rendered

Definition at line 75 of file DataEntry.php.


The documentation for this class was generated from the following file: