<?php
namespace Modules\Admin\Config\Services\Basic;

class View_Utils_AddGroup extends \App\Mvc\View_Utils_FormAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\View_Utils_FormAbstract::getForm()
	 */
	public function getForm()
	{

		$form = \Engine\Form\General::create();

		// add container
		$fieldset = \Engine\Form\Container\Fieldset::create();
		$form->addContainer($fieldset);

		// group code
		$code = new \Engine\Form\Input\Text($this->lang['addGroup']['formFields']['code'], 'code', $this->values['code']);
		$code->setMandatory(true);
		$code->setValidatorParam('maxLength', '20');
		$code->setValidatorParam('minLength', '1');
		if ($this->values['action'] == 'update') {
			$code->setDisabled(true);
		}
		$fieldset->addElement($code);

		// group name
		$name = new \Engine\Form\Input\Text($this->lang['addGroup']['formFields']['name'], 'name', $this->values['name']);
		$name->setMandatory(true);
		$name->setValidatorParam('maxLength', '100');
		$name->setValidatorParam('minLength', '1');
		$fieldset->addElement($name);

		$form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1));
		return $form;
	}
}