\recordSelectField

Defines a recordSelect field, allowing to display a list of records from another table inside a form field. recordEditTable and recordSelectField allow to create a one to may relationship.

The recordSelect field retains in its 'value' parameter the list of uids of the records associated with the current record. The field can be run in 2 modes according to the developer's needs: 'initItemsSQL' or 'addItemsSQL'. 'initItemsSQL' pre-populates the field with the result of the configured SQL request, allowing the user to pick among those items those which he wishes to select. 'addItemsSQL' starts with an empty field and allows the user to add items among the set defined by the SQL request.

Summary

Methods
Properties
Constants
displayField()
getSelectItems()
onSave()
getCSS()
getTopJS()
getBottomJS()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

displayField()

displayField(  $f) 

Returns the HTML code for displaying the field, initialized with the data supplied in $fieldData

Creates a select box populated with records from other tables. Records can be edited, deleted, copied, pasted in the same field or an other field displaying the same type of records. Records can be created too. All these features can be enabled / disabled by configurable options. VERY IMPORTANT : the added record (a dbRecord extended class) MUST feature a column/field named parent_uid of type int(11), which is required for the copy paste operations. This column will/must contain the uid of the parent record where the current field is displayed as an option in a select field.

Parameters

$f

fieldData : this stdClass object contains all the field info. Defining the function arguments into an object avoids redefining all existing functions already issued when a new argument requires to be added to the calls. $f->formID // value of the id attribute of the

tag this field is included in $f->mode // the mode value allows discriminating between templates (mode=="template|") and microtemplates (mode=="micro|") $f->dataType // this is an numeric array of every arguments included in the 'dataType' index of the field. example : $MyField['dataType']='input text' gets available as array(0 => 'input', 1=> 'text') $f->key // this is the unique key (or field name/identifier ) for the currentField. Exemple : 'clientName' $f->fieldData // this is the data array of the current field $f->recordUid // the uid (Unique ID) of the record containing the current field $f->recordClassName // the class name of the record containing the current field $f->record // all the data for the record containing the current field $f->microKey // field name when processing a microTemplate field (only used when mode=="micro|") $f->microIndex // sorting index when processing a microTemplate field (only used when mode=="micro|")

getSelectItems()

getSelectItems(  $f, boolean  $returnFullData = false) : array

returns an array of uid => title for options displayed in recordSelect

Parameters

$f

an stdClass containing the required parameters. Must be defined like this :

         $f = new stdClass();

$f->key = $recordKey; $f->recordClassName = $recordClass; $f->fieldData = $record->data[$recordKey]; $f->record = $record;

boolean $returnFullData

instead of feeding the return array with the option title, the function will return all the option record data

Returns

array

onSave()

onSave(  $fieldData,   $value) : mixed

Process the field value prior saving it to the database, whenever inner value adaptation is required, for SQL strict compliance for example.

This is executed after 'preRecord' processing functions.

Parameters

$fieldData

this is the data array of the current field

$value

this is the submited value

Returns

mixed

getCSS()

getCSS() 

Returns the HTML code necessary to add the CSS files required by this field

getTopJS()

getTopJS() 

Returns the HTML code necessary to add at the top of the HTML page the JS files or scripts required by this field

getBottomJS()

getBottomJS() 

Returns the HTML code necessary to add at the bottom of the HTML page the JS files or scripts required by this field