IDBSelect
From FiFormsWiki
class iDBSelect extends iInput
Data Bound Selection Box. The rows in the drop-down are loaded from an SQL query or array, and the selected items is stored as a value in a field.
Contents |
Properties
| $radioStyle | If true, outputs radio buttons instead of a select box. |
| $rowQuery | SQL query used to fill the the select box. This query should return exactly 1 or 2 columns. If 2 columns, the first is values stored in the field and the second is the values displayed in the dropdown box. This can also be an array of values or a 2-dimensional array of containting key/value pairs instead of an SQL statement. |
Properties inherited from iInput: $caption $currentRec $dbField $error $errorMsg $formatStr $formatStrRO $otherTags $readOnly $section $value $valueToSave
Method Detail
Methods inherited from iInput
- checkRO
- drawInput
- getValueToSave
- hide
- iInput
- throwError
iDBSelect
Constructs a new iDBSelect.
Syntax: iDBSelect($dbField,$caption,$rowQuery,$radioStyle)
Parameters
$dbField - Bound database field, containing value or key in select box.
$caption - Field caption
$rowQuery - Either an SQL statement returning values or key/value pairs, OR an array of values or an array of 2-element arrays (key/value pairs).
$radioStyle - (optional) if TRUE, output radio buttons instead of a select box.
Examples
Example
Select box bound to SQL query returning 2 values
$frm->inputs[] = new iDBSelect(
"ST",
"State", "SELECT ST_ID, ST_ABBR FROM STATES" );
Example
Select box bound filled with single array of values
$frm->inputs[] = new iDBSelect(
"PER_STATUS",
"Marital Status", array("Single","Married","Separated","Divorced","Other") );
Example
Select box with array of name/value pairs
$frm->inputs[] = new iDBSelect(
"PER_STATUS",
"Marital Status", array(array(1,"Single"), array(2,"Married"), array(3,"Separated"), array(4,"Divorced"), array(5,"Other") ), TRUE );
Returns
A new iDBSelect object


