<?php

namespace Modules\Admin\DocumentTemplates;

class View_Utils_FormClone extends \App\Mvc\View_Utils_FormAbstract
{

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

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

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

		// document status
		$activeArr = ['1'=> $this->lang['formFields']['activeYes'], '0'=> $this->lang['formFields']['activeNo']];
		$active = new \Engine\Form\Input\Radio($this->lang['formFields']['active'], 'active', $this->values['active']);
		$active->setPossibleValues($activeArr);
		$form->addElement($active);

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

		// document type - this field is populated with document types for the initial pivot
		$docType = new \App\Form\Input\Select_DocumentType($this->lang['formFields']['docType'], 'docType', $this->values['docType']);
		$docType->importFromConfig($entCfg['docType']);
		$docType->setDefaultOptionText($this->lang['formFields']['docType_default']);
		$docType->setPivot($this->values['pivot']);
		$docType->showDefaultOption(true);
		$form->addElement($docType);



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

		return $form;
	}
}