<?php
namespace SabaiApps\Directories\Component\Search\Controller;

use SabaiApps\Directories\Context;
use SabaiApps\Directories\Component\Form;

class Search extends Form\Controller {

	protected function _doGetFormSettings( Context $context, array &$storage ) {
		$this->_submitable = $context->getContainer() === '#drts-content';
		return $this->Search_Form(
			$context->bundle,
			$this->Search_Form_params( $context->getRequest()->getParams() ),
			$context->settings ?: array(),
			$this->_getDefaultSubmitCallback( $context )
		);
	}

	public function submitForm( Form\Form $form, Context $context ) {
		$context->setRedirect( $this->Url( $context->bundle->getPath(), $this->Search_Form_processParams( $context->getRequest()->getParams() ) ) );
	}
}
