/** * @param form_persistentdocument_baseform $form * @param block_BlockRequest $formRequest * @param validation_Errors $errors * @param array<String> $scriptArray * @return String * @deprecated */ public function renderForm($form, $formRequest, $errors, &$scriptArray) { $scriptArray[] = 'modules.form.lib.js.date-picker.date'; $scriptArray[] = 'modules.form.lib.js.date-picker.date_' . RequestContext::getInstance()->getLang(); $scriptArray[] = 'modules.form.lib.js.date-picker.jquery-bgiframe'; $scriptArray[] = 'modules.form.lib.js.date-picker.jquery-dimensions'; $scriptArray[] = 'modules.form.lib.js.date-picker.jquery-datePicker'; $scriptArray[] = 'modules.form.lib.js.form'; $markup = $form->getMarkup(); if (!$markup) { $markup = 'default'; } try { $template = TemplateLoader::getInstance()->setMimeContentType(K::HTML)->setPackageName('modules_form')->setDirectory('templates/markup/' . $markup)->load('Form'); $template->setAttribute('form', $form); $template->setAttribute('selfUrl', $_SERVER['REQUEST_URI']); if ($formRequest->hasParameter(form_FormConstants::BACK_URL_PARAMETER)) { $template->setAttribute('backUrl', $formRequest->getParameter(form_FormConstants::BACK_URL_PARAMETER)); } else { $template->setAttribute('backUrl', $_SERVER['HTTP_REFERER']); } if (!is_null($errors)) { $template->setAttribute('errors', $errors); } $fieldContents = array(); $this->buildContentsFromRequest($form->getDocumentNode()->getChildren(), $fieldContents, $formRequest, $form); $template->setAttribute('requestParameters', $formRequest->getParameters()); $template->setAttribute('elements', $fieldContents); return $template->execute(true); } catch (Exception $e) { Framework::exception($e); } return null; }
/** * @param form_persistentdocument_baseform $form * @param integer[] $excludeIds */ public function getValidActivationFields($form, $excludeIds = array()) { $query = form_FieldService::getInstance()->createQuery(); $query->add(Restrictions::descendentOf($form->getId())); if (f_util_ArrayUtils::isNotEmpty($excludeIds)) { $query->add(Restrictions::notin('id', $excludeIds)); } $validFields = array(); foreach ($query->find() as $field) { if ($field instanceof form_persistentdocument_boolean || $field instanceof form_persistentdocument_list) { $validFields[] = $field; } } return $validFields; }
/** * @param array<TreeNode> $nodes * @param block_BlockRequest $request * @param form_persistentdocument_baseform $form * @return array */ protected function getContentsFromRequest($nodes, $request, $form) { $contents = array(); $markup = $form->getMarkup(); foreach ($nodes as $node) { $document = $node->getPersistentDocument(); if ($document instanceof form_persistentdocument_group) { $templateObject = TemplateLoader::getInstance()->setPackageName('modules_form')->setDirectory('templates/markup/' . $markup)->load('Form-Group'); $elements = $this->getContentsFromRequest($node->getChildren(), $contents, $request, $markup); $attributes = array('id' => $document->getId(), 'label' => $document->getLabel(), 'description' => $document->getDescription(), 'elements' => $elements); } else { if ($document instanceof form_persistentdocument_field) { $templateObject = TemplateLoader::getInstance()->setPackageName('modules_form')->setDirectory('templates/markup/' . $markup)->load($document->getSurroundingTemplate()); $html = FormHelper::fromFieldDocument($document, $request->hasParameter($document->getFieldName()) ? $request->getParameter($document->getFieldName()) : $document->getDefaultValue()); $attributes = array('id' => $document->getId(), 'label' => $document->getLabel(), 'description' => $document->getHelpText(), 'required' => $document->getRequired(), 'display' => f_util_ClassUtils::methodExists($document, 'getDisplay') ? $document->getDisplay() : '', 'html' => $html); } else { if ($document instanceof form_persistentdocument_freecontent) { $templateObject = TemplateLoader::getInstance()->setPackageName('modules_form')->setDirectory('templates/markup/' . $markup)->load('Form-FreeContent'); $attributes = array('id' => $document->getId(), 'label' => $document->getLabel(), 'description' => $document->getText(), 'required' => false, 'html' => ''); } } $templateObject->setAttribute('field', $attributes); } $contents[$document->getId()] = $templateObject->execute(); } return $contents; }