Hello!
I'm working over the CMP now. Working like in CMP development tutorial and rus translation
modx.ws/razrabotka-dopolneniya-modx-revolution-2. Almost at last step i've got problem - can't place data from SuperBoxSelect to DB.
Custom component looks like here:
Repstat.combo.Work = function(config) {
config = config || {};
Ext.applyIf(config,{
xtype:'superboxselect'
,triggerAction: 'all'
,store: new Ext.data.ArrayStore({
id: 0
,fields: ['work']
,data: [
['repair']
,['destruct']
]
})
,displayField: 'work'
,valueField: 'work'
,mode: 'local'
});
Repstat.combo.Work.superclass.constructor.call(this,config);
};
Ext.extend(Repstat.combo.Work,Ext.ux.form.SuperBoxSelect);
Ext.reg('repstat-superCombo-work',Repstat.combo.Work);
Call in Create Window:
Repstat.window.CreateStatus = function(config) {
config = config || {};
Ext.applyIf(config,{
title: _('repstat.status_create')
,url: Repstat.config.connectorUrl
,baseParams: {
action: 'mgr/repstat/create'
}
,fields: [{
...
},{
xtype: 'repstat-superCombo-work'
,fieldLabel: _('repstat.work')
,name: 'work[]'
,hiddenName: 'work'
,anchor: '100%'
},{
...
}]
});
Repstat.window.CreateStatus.superclass.constructor.call(this,config);
};
Ext.extend(Repstat.window.CreateStatus,MODx.Window);
Ext.reg('repstat-window-status-create',Repstat.window.CreateStatus);
Create processor:
<?php
class statusCreateProcessor extends modObjectCreateProcessor {
public $classKey = 'status';
public $languageTopics = array('repstat:default');
public $objectType = 'repstat.status';
public function beforeSave() {
$imei = $this->getProperty('imei');
if (empty($imei)) {
$this->addFieldError('imei',$this->modx->lexicon('repstat.status_err_ns_imei'));
} else if ($this->doesAlreadyExist(array('imei' => $imei))) {
$this->addFieldError('imei',$this->modx->lexicon('repstat.status_err_ae'));
}
return parent::beforeSave();
}
}
return 'statusCreateProcessor';
I tried localize the problem next way: add this PHP code into the beforeSave() function
$work[] = $this->getProperty('work');
$this->addFieldError('work',$work[1]);
This case i've got "Value of this field is wrong" <- translated from rus.
If $work[0] than i get last added element.
Where i may read more about processors working and where is my fault? How i can put some values from superselectbox into DB? I'm newbie in MODX(
Thank you for respond and sorry for my bad english.