<?php
 namespace Modules\Admin\Config\CurrencyTypes; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $form = \Engine\Form\General::create(); $form->setStyle('width', 250); $fieldset=\Engine\Form\Container\Fieldset::create(); $form->addContainer($fieldset); $fld=new \Engine\Form\Input\Text($this->lang['form']['fields']['code']['label'], 'id', $this->values['id']); $fld->setMandatory(); if ($this->controller->getAction()=='update') { $fld->setDisabled(true); } $fld->setValidatorParam('maxLength', 20); $fieldset->addElement($fld); $fld=new \Engine\Form\Input\Text($this->lang['form']['fields']['name']['label'], 'name', $this->values['name']); $fld->setMandatory(); $fld->setValidatorParam('maxLength', 50); $fieldset->addElement($fld); if(\App\Config\CurrencyTypes::getAdmin()->getDefaultCurrencyType() != $this->values['id']) { $inputSelectFormula=new \Engine\Form\Input\Select($this->lang['form']['fields']['formula']['label'], 'formulaType', $this->values['formulaType']); $inputSelectFormula->setPossibleValues([ ''=> $this->lang['form']['fields']['formula']['options']['none'], 'simple'=> $this->lang['form']['fields']['formula']['options']['simple'], 'complex'=> $this->lang['form']['fields']['formula']['options']['complex'] ] ); $fieldset->addElement($inputSelectFormula); $inputSimpleFormula=new \App\Form\Input\CurrencyTypeFormula($this->lang['form']['fields']['formula_simple']['label'], 'simpleFormula', $this->values['simpleFormula']); $inputSimpleFormula->setDefaultValue($this->values['simpleFormula']['parent']); $fieldset->addElement($inputSimpleFormula); $complexFormulasList=[]; foreach (\App\Config\Currencies::getAdmin()->getAll() as $codeCurrency=>$valCurrency) { if ($codeCurrency!=\App\Config\Currencies::getInstance()->getDefaultCurrency()) { $inputComplexFormula[$codeCurrency]=new \App\Form\Input\CurrencyTypeFormula(sprintf($this->lang['form']['fields']['formula_complex']['label'],$codeCurrency), 'complexFormula['.$codeCurrency.']', $this->values['complexFormula'][$codeCurrency]); $inputSimpleFormula->setDefaultValue($this->values['complexFormula'][$codeCurrency]['parent']); $fieldset->addElement($inputComplexFormula[$codeCurrency]); $complexFormulasList[]=$inputComplexFormula[$codeCurrency]; } } $inputSelectFormula->setControlledElements( [ 'simple'=> [$inputSimpleFormula], 'complex'=>$complexFormulasList, ],'hide' ); } $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); return $form; } }