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.
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 an EntryField into HTML
text
Render
()