/** * Adds any child forms for this form. * @param DOMNode $detailNode. The major node which contains the formBrowser we are creating * @param I2CE_MagicDataNode $formConfig /modules/forms/forms/$formName * @param I2CE_Form $formObj the form object for the form we are displaying ( or null.if we are not looking at a particular record) * @returns boolean. Return false if none were added, true if child forms were added. */ public function addChildForms($detailNode, $formConfig, $formObj) { $view_child = ''; $child_forms = array(); $formConfig->setIfIsSet($child_forms, "meta/child_forms", true); if (count($child_forms) > 0) { $view_child = "formBrowser/showForm"; } $prefixNode = $this->template->getElementById('child_fb_prefix', $detailNode); if ($prefixNode instanceof DOMNode) { $prefixNode->setAttribute('value', $this->formBrowserPrefix); } $this->template->setDisplayDataImmediate('form_view_child', $view_child, $detailNode); $selectNode = $this->template->getElementById('child_form_select', $detailNode); $added = false; if ($selectNode instanceof DOMNode && $formObj instanceof I2CE_Form) { foreach ($child_forms as $child) { $childIds = $formObj->getChildIds($child); foreach ($childIds as $childId) { $added = true; $selectNode->appendChild($this->template->createElement('option', array('value' => $child . ':' . $childId), $child . ' Id: ' . $childId)); } } } else { if ($selectNode instanceof DOMNode) { foreach ($child_forms as $child) { $added = true; $selectNode->appendChild($this->template->createElement('option', array('value' => $child), $child)); } } } foreach (array("form_view_child", "form_view_child_button") as $id) { $formNode = $this->template->getElementById($id, $detailNode); if ($formNode instanceof DOMNode) { $formNode->setAttribute('id', $this->formBrowserPrefix . '_' . $id); } } if ($this->page->hasAjax() && $added) { $this->page->addAjaxUpdate($this->formBrowserPrefix . '_content', $this->formBrowserPrefix . '_form_view_child_button', 'click', "formBrowser/{$this->formBrowserPrefix}", $this->formBrowserPrefix . '_content', true, $this->formBrowserPrefix . '_form_view_child', true); } if (!$added) { return false; } else { return true; } }