if (isset($data['id']) && $data['id'] > 0) { $element = $modx->getObject('RadFormElements', (int) $data['id']); $data['update_time'] = date('Y-m-d H:g:i'); } else { $element = $modx->newObject('RadFormElements'); $data['create_time'] = date('Y-m-d H:g:i'); } $data['form_id'] = $form_id; if (isset($data['config']['parent']) && $element_to_id[$data['config']['parent']]) { $data['parent_id'] = $element_to_id[$data['config']['parent']]; } if (isset($data['config']['group_element']) && $element_to_id[$data['config']['group_element']]) { $data['group_element_id'] = $element_to_id[$data['config']['group_element']]; } $data['html_id'] = $eID; $data['config'] = json_encode($data['config']); if (!isset($data['validation_rules'])) { $data['validation_rules'] = array(); } $data['validation_rules'] = json_encode($data['validation_rules']); $element->fromArray($data); if (!$element->save()) { $modx->log(modX::LOG_LEVEL_ERROR, '[RadUiBuildFromArray] Could not save the element: ' . $eID . ' data: ' . print_r($data, true)); } $id_to_element[$element->get('id')] = $element->get('html_id'); $element_to_id[$element->get('html_id')] = $element->get('id'); } } // build the tree/paths: $paths->buildTree(array('form_id' => $radForm->get('id'))); return 'Saved the elements';
/** * Update Dependants, children, parents, ect.. * @Override this method is meant to be overridden * @param (object) $item * @return Boolean */ public function updateDependants($item) { require_once $this->modx->radui->getConfig('raduiPath') . 'matericalizedpaths.class.php'; $paths = new MaterializedPaths($this->modx, $config = array()); $paths->buildTree(array('form_id' => $item->get('form_id'))); return TRUE; }