<?php

namespace Modules\TaskManagement\Categories;

class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract
{

	/**
	 * Creates the form for category insert/update.
	 * @see \App\Mvc\View_Utils_FormAbstract::getForm()
	 */
	public function getForm()
	{
		// load the configurations for this form
		$cfg = \Entity\TaskCategory::loadCFG();

		$form = \Engine\Form\General::create();
		$form->setStyle('width', '300');
		$form->addContainer(\Engine\Form\Container\Fieldset::create());

		// category name
		$fld = new \Engine\Form\Input\Text($this->lang['formFields']['category'], 'category', $this->values['category']);
		$fld->importFromConfig($cfg['category']);
		$form->addElement($fld);

		// description
		$fld = new \Engine\Form\Input\Textarea($this->lang['formFields']['description'], 'description', $this->values['description']);
		$fld->importFromConfig($cfg['description']);
		$form->addElement($fld);

		// category id (for update operation)
		if ($this->controller->getAction()=='update') {
			$form->addElement(new \Engine\Form\Input\Hidden('', 'id', $this->values['id']));
		}

		// submit button
		$form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1));

		return $form;

	}

}