/** * Logic for both create and update actions. */ protected function createUpdateCommon() { $this->_action = get_class($this); // Recursively processing all forms. if (!isset($this->formSettings['forms']['id'])) { foreach ($this->formSettings['forms'] as $key => $value) { $this->formSettings['forms'][$key] = $this->processFormSettingsForm($this->formSettings['forms'][$key]); } } else { $this->formSettings['forms'] = $this->processFormSettingsForm($this->formSettings['forms']); } $formManager = new FormManager($this->formSettings); $formManager->process(); // Render with form variables. Blocs type forms have a variable that is an array containing its sub-forms as well. $renderArray = array(); foreach ($this->_formIds as $varName => $formIdArr) { if ($formIdArr[1] !== null) { $blocsForm = $formManager->getForm($formIdArr[0]); $renderArray[$varName] = array($formManager->getModels($formIdArr[0])); foreach ($blocsForm->forms as $blocsSubForm) { $renderArray[$varName][substr($blocsSubForm->id, 18, -4)] = $blocsSubForm->models; } } else { $renderArray[$varName] = $formManager->getModels($formIdArr[0]); } } $this->controller->render(lcfirst($this->_action), $renderArray); }