<?php
 namespace Modules\Admin\Config\Customers\Flags; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $form = \Engine\Form\General::create(); $form->setStyle('width', 250); $flags = \App\Config\CustomersFlags::getAdmin()->getAvailableCodes(); $possibleValues = []; foreach($flags as $code) { $possibleValues[$code]=$this->lang['flagsList'][$code]; } if(empty($possibleValues) && $this->controller->getAction()=='insert') { $form->addMessage('info', $this->lang['form']['warning']['noAvailableCodes']); } else { $fieldset=\Engine\Form\Container\Fieldset::create(); $form->addContainer($fieldset); $flagCodeInput = new \Engine\Form\Input\Select($this->lang['form']['fields']['code']['label'], 'id', $this->values['id']); $flagCodeInput->setMandatory(); if ($this->controller->getAction()=='update') { $flagCodeInput->setPossibleValue($this->values['id'], $this->lang['flagsList'][$this->values['id']]); $flagCodeInput->setDisabled(); } else { $flagCodeInput->setPossibleValues($possibleValues); } $fieldset->addElement($flagCodeInput); $flagNameInput = new \Engine\Form\Input\Text($this->lang['form']['fields']['name']['label'], 'name', $this->values['name']); $flagNameInput->setMandatory(); $flagNameInput->setValidatorParam('maxLength', 50); $fieldset->addElement($flagNameInput); $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); } return $form; } }