<?php
namespace Modules\Admin\Config\CorporateCollectionProfiles;

class View_Utils_FormFilters extends \App\Mvc\View_Utils_FormAbstract
{

	/**
	 * Creates the form for filters
	 * @see \App\Mvc\View_Utils_FormAbstract::getForm()
	 */
	public function getForm()
	{
		$fieldsValues = $this->values['listingParams']->getFilters();

		$form=\Engine\Form\Filters::create();
		$form->setColumns(2);

		// code name
		$nameFld=new \Engine\Form\Input\Text($this->lang['index']['filters']['name'], 'filters[name]', $fieldsValues['name']);
		$form->addElement($nameFld);

		// attachment
 		$attachmentFld = new \Engine\Form\Input\Select($this->lang['index']['filters']['attachment'], 'filters[attachment]', $fieldsValues['attachment']);
		$attachmentFld->showDefaultOption();
		$options = [];
		foreach($this->globalCfg['corporateCollectionProfiles']['attachmentsList'] as $att) {
			$options[$att] = $this->globalLang['corporateCollection']['attachments'][$att];
		}
		$attachmentFld->setPossibleValues($options);
		$form->addElement($attachmentFld);

		$form->setJsCallback('MVC.listing.installedHandlers["listing"].reloadAndResetListing');
		$form->loadMissingDefaultValues($this->values['listingParams']->getDefaultFilters());
		return $form;
	}

}