in your nested grid, do you have StaffMemberCategories or StaffCategory as the classname?
you also should have
"use_as_fallback":"1",
what is your getlist.php - code currently?
This is what I add in the lines 167 - 193
$staffCategories = array();
$c2 = $modx->newQuery('StaffMemberCategories');
$c2->where(array('staff_id'=>$resource_id));
if ($staffCategoryCollection = $modx->getCollection('StaffMemberCategories',$c2)){
foreach ($staffCategoryCollection as $staffCategoryObject){
$staffCategories[] = $staffCategoryObject->get('category_id');
}
}
//print_r($resCategories);
//$c->sortby($sort,$dir);
//$c->prepare();echo $c->toSql();
$rows = array();
if ($collection = $xpdo->getCollection($classname, $c)) {
$pk = $xpdo->getPK($classname);
foreach ($collection as $object) {
$row = $object->toArray();
$row['id'] = !isset($row['id']) ? $row[$pk] : $row['id'];
$row['joined'] = in_array($row['id'],$staffCategories) ? '1' : '0';
$rows[] = $row;
}
}
I was talking about this one
core/components/{packagename}/processors/mgr/{processorspath}/getlist.php
<?php
$config = $modx->migx->customconfigs;
$prefix = $modx->getOption('prefix', $config, null);
$packageName = $config['packageName'];
$packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
$modx->addPackage($packageName, $modelpath, $prefix);
$classname = $config['classname'];
$joinclass = 'StaffMemberCategories';
$resource_id = $modx->getOption('resource_id', $scriptProperties, 0);
$object_id = $modx->getOption('object_id', $scriptProperties, 0);
switch ($scriptProperties['idx']) {
case '1':
$joinobject = $modx->newObject($joinclass);
$joinobject->set('staff_id', $resource_id);
$joinobject->set('category_id', $object_id);
$joinobject->save();
break;
case '0':
if ($joinobject = $modx->getObject($joinclass, array('staff_id' => $resource_id, 'category_id' => $object_id))) {
$joinobject->remove();
}
break;
default:
break;
}
return $modx->error->success()$resource_id = $modx->getOption('resource_id', $scriptProperties, 0);$staff_id = $modx->getOption('co_id', $scriptProperties, 0);<?php
$config = $modx->migx->customconfigs;
$prefix = $modx->getOption('prefix', $config, null);
$packageName = $config['packageName'];
$packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
$modx->addPackage($packageName, $modelpath, $prefix);
$classname = $config['classname'];
$joinclass = 'StaffMemberCategories';
$staff_id = $modx->getOption('co_id', $scriptProperties, 0);
$object_id = $modx->getOption('object_id', $scriptProperties, 0);
switch ($scriptProperties['idx']) {
case '1':
$joinobject = $modx->newObject($joinclass);
$joinobject->set('staff_id', $staff_id);
$joinobject->set('category_id', $object_id);
$joinobject->save();
break;
case '0':
if ($joinobject = $modx->getObject($joinclass, array('staff_id' => $staff_id, 'category_id' => $object_id))) {
$joinobject->remove();
}
break;
default:
break;
}
return $modx->error->success()switch ($scriptProperties['idx']) {
case '1':
if ($joinobject = $modx->getObject($joinclass, array('staff_id' => $staff_id, 'category_id' => $object_id))) {
//do nothing in that case
} else {
$joinobject = $modx->newObject($joinclass);
$joinobject->set('staff_id', $staff_id);
$joinobject->set('category_id', $object_id);
$joinobject->save();
}
break;
case '0':
if ($joinobject = $modx->getObject($joinclass, array('staff_id' => $staff_id, 'category_id' => $object_id))) {
$joinobject->remove();
}
break;
default:
break;
}