KenedoProperty Type Join

PHP class: KenedoPropertyJoin
Recommended column type: INT UNSIGNED NULL
Object var: As property name -

With the ‘join’ type you create a reference to another model’s primary key. In the backend’s edit screen, the property will show a dropdown with the records of the referenced model.

Object variable names

KenedoModel::getRecord and getRecords will add these object variables (assuming property name is product_id):

  • $record->product_id - ID of the referenced record

  • $record->product_id_display_value - in the property setting ‘propNameDisplay’ you specify the name of a property. You’ll find the record value for that property in this.

Typical property settings array

In the property settings you give information about the referenced model and properties.

$propDefs['product_id'] = array( 'name'=>'product_id', 'label'=>KText::_('Product'), 'type'=>'join', 'modelClass'=>'ConfigboxModelAdminproducts', 'modelMethod'=>'getRecords', 'propNameKey'=>'id', 'propNameDisplay'=>'title', 'defaultlabel'=>KText::_('Select Product'), 'positionForm'=>1000, );

Property Settings

modelClass

Required: yes
Valid values: string - class name of a KenedoModel

You supply the name of the model you want to reference to. It can be a built-in model or a custom one

modelMethod

Required: yes
Valid values: string - name of a method of the modelClass.

The system will use this method to get the data for the edit screen dropdown. Typically the KenedoModel getRecords suffices. The given function needs to return an array of objects - the object needs to have the variable names provided in ‘propNameKey’ and ‘propNameDisplay’.

propNameKey

Required: yes
Valid values: string - name of the ID property in the modelClass.

You’ll want to use the referenced model’s primary key property (type ‘id’).

propNameDisplay

Required: yes
Valid values: string - name a property in the modelClass.

Supply a property of the referenced model. The values of that property will display in the edit screen dropdown.

defaultlabel

Required: no
Valid values: string

Text to show in the dropdown as NULL option - when no record was selected yet.