<?php
namespace Modules\Admin\Config\Remarks\AssistedInputs; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $form = \Engine\Form\General::create(); $fieldset = \Engine\Form\Container\Fieldset::create(); $form->addContainer($fieldset); $nameFld = new \Engine\Form\Input\Text($this->lang['index']['labels']['remarkFormat'], "format", $this->values['format']); $nameFld->setDisabled(); $fieldset->addElement($nameFld); $fieldset = \Engine\Form\Container\Fieldset::create($this->lang['index']['fieldsets']['serviceTypes']); $fieldset->setCollapsible(); $fieldset->setCollapsed(); $form->addContainer($fieldset); $serviceTypes = \App\Config\Services_Basic::getInstance()->getAll(); foreach ($serviceTypes as $groupDetails) { $groupLabel = $groupDetails['name']; $possibleValues = []; if ($groupDetails['list']) { foreach ($groupDetails['list'] as $code =>$serviceDetails) { $possibleValues[$code] = $serviceDetails['name']; } } $checkboxesServices = new \Engine\Form\Input\Checkboxes($groupLabel, 'services', $this->values['services'], $possibleValues); $checkboxesServices->setStyle('renderMode', 'aligned'); $fieldset->addElement($checkboxesServices); } foreach ($this->values['vars'] as $indexVar => $varDetails) { $fieldset = \Engine\Form\Container\Fieldset::create($varDetails['name']); $form->addContainer($fieldset); $fieldset->setCollapsible(); $assistedInputFld = new \Engine\Form\Input\Checkbox($this->lang['index']['labels']['assistedInput'], "vars[{$indexVar}][assistedInput]", $this->values['vars'][$indexVar]['assistedInput']); $fieldset->addElement($assistedInputFld); $nameFld = new \Engine\Form\Input\Text($this->lang['index']['labels']['name'], "vars[{$indexVar}][assistedInputDetails][name]", $this->values['vars'][$indexVar]['assistedInputDetails']['name']); $nameFld->setTooltip($this->lang['index']['tooltips']['name']); $fieldset->addElement($nameFld); $categoryFld = new \Engine\Form\Input\Text($this->lang['index']['labels']['category'], "vars[{$indexVar}][assistedInputDetails][category]", $this->values['vars'][$indexVar]['assistedInputDetails']['category']); $categoryFld->setTooltip($this->lang['index']['tooltips']['category']); $fieldset->addElement($categoryFld); $descriptionFld = new \Engine\Form\Input\Textarea($this->lang['index']['labels']['description'], "vars[{$indexVar}][assistedInputDetails][description]", $this->values['vars'][$indexVar]['assistedInputDetails']['description']); $descriptionFld->setTooltip($this->lang['index']['tooltips']['description']); $fieldset->addElement($descriptionFld); $multiLineFld = new \Engine\Form\Input\Checkbox($this->lang['index']['labels']['multiLine'], "vars[{$indexVar}][assistedInputDetails][multiLine]", $this->values['vars'][$indexVar]['assistedInputDetails']['multiLine']); $multiLineFld->setTooltip($this->lang['index']['tooltips']['multiLine']); $fieldset->addElement($multiLineFld); if ($varDetails['type'] == 'select') { $containerOption=\Engine\Form\Container\Table::create('option'); foreach ($varDetails['options'] as $idxOption => $optionValue) { $selectOptionsFld[$idxOption] = new \Engine\Form\Input\Text($optionValue, "vars[{$indexVar}][assistedInputDetails][selectOptions][{$optionValue}]", $this->values['vars'][$indexVar]['assistedInputDetails']['selectOptions'][$optionValue]); $containerOption->addElement($selectOptionsFld[$idxOption]); } $input = new \Engine\Form\Input\Label($this->lang['index']['labels']['selectOptions']); $input->addContainer($containerOption); $input->setTooltip($this->lang['index']['tooltips']['selectOptions']); $input->setStyle('asElement', true); $fieldset->addElement($input); $assistedInputFld->setControlledElements([true => [$input, $nameFld, $categoryFld, $multiLineFld]],'disable'); } elseif (in_array($varDetails['type'], ['date', 'currency'])) { $assistedInputFld->setControlledElements([true => [$nameFld, $categoryFld, $descriptionFld, $multiLineFld]],'disable'); } else { $autocompleteTypeFld=new \Engine\Form\Input\Select($this->lang['index']['labels']['autocompleteType'], 'vars['.$indexVar.'][assistedInputDetails][autocompleteType]', $this->values['vars'][$indexVar]['assistedInputDetails']['autocompleteType']); $autoTypePossVal=[]; foreach (\App\Config\Remarks::getAdmin()->getValidRemarkVarAutocompleteTypes() as $autoType) { $autoTypePossVal[$autoType] = $this->lang['index']['autocompleteType'][$autoType]; } $autocompleteTypeFld->setPossibleValues($autoTypePossVal); $autocompleteTypeFld->showDefaultOption(); $fieldset->addElement($autocompleteTypeFld); $controlledElements = [$nameFld, $categoryFld, $descriptionFld, $multiLineFld]; if(!in_array($varDetails['type'], ['float','boolean'])) { $controlledElements[] = $autocompleteTypeFld; } $assistedInputFld->setControlledElements([true => $controlledElements],'disable'); } } $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); return $form; } } 