Hello,
I am trying to make my extras, all is fine except combo box... I want from combo box to show data from another table (names and id as identificator), but really don’t know how... I read some topics here, but it didn’t help me
Here is my window + combo code
Indications.combo.Type = function(config){
config = config || {};
Ext.applyIf(config,{
hiddenName: 'id',
displayField: 'name',
valueField: 'id',
fields: ['id','name'],
url: '/assets/components/indications/connector-type.php',
});
Indications.combo.Type.superclass.constructor.call(this,config);
};
Ext.extend(Indications.combo.Type,MODx.combo.ComboBox);
Ext.reg('indications-combo-type',Indications.combo.Type);
Indications.window.CreateIndication = function(config) {
config = config || {};
Ext.applyIf(config,{
title: _('indications.indication_create')
,url: Indications.config.connectorUrl
,baseParams: {
action: 'mgr/indication/create'
}
,fields: [{
xtype: 'textfield'
,fieldLabel: _('indications.name')
,name: 'name'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('indications.application_count')
,name: 'application_count'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('indications.application_length')
,name: 'application_length'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('indications.using_addons')
,name: 'using_addons'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('indications.application_docs')
,name: 'application_docs'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('indications.acupressure_area')
,name: 'acupressure_area'
,width: 300
},{
xtype: 'textfield'
,fieldLabel: _('indications.link')
,name: 'link'
,width: 300
},{
fieldLabel: _('indications.nameType')
,name: 'indication_type'
,width: 300
,xtype: 'indications-combo-type'
}]
});
Indications.window.CreateIndication.superclass.constructor.call(this,config);
};
Ext.extend(Indications.window.CreateIndication,MODx.Window);
Ext.reg('indications-window-indication-create',Indications.window.CreateIndication);
Here is my connector (hope i do it well)
<?php
$c = $modx->newQuery('IndicationType');
$indications = $modx->getIterator('IndicationType', $c);
/* iterate */
$list = array();
foreach ($indications as $indication) {
$indicationArray = $indication->toArray();
$list[]= $indicationArray;
}
return $this->outputArray($list);
Here is, how my tables look like
<?xml version="1.0" encoding="UTF-8"?>
<model package="indications" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
<object class="Indication" table="indications" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="application_count" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="application_length" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="using_addons" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
<field key="application_docs" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="acupressure_area" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="indication_type" dbtype="int" precision="10" phptype="string" null="false" default=""/>
<field key="link" dbtype="int" phptype="integer" null="true" default=""/>
<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="Link" class="modResource" local="link" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="IndicationType" class="IndicationType" local="indication_type" foreign="id" cardinality="one" owner="foreign"/>
</object>
<object class="IndicationType" table="indication_types" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="64" phptype="string" null="false" default=""/>
<field key="css_name" dbtype="varchar" precision="64" phptype="string" null="false" default=""/>
<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
</object>
</model>