<?php
namespace App\Form\Input;

class FormulaTextarea extends \Engine\Form\Input\Textarea
{

	protected $class = "formulaTextarea";

	protected $pivot=null;


	public function __construct($label=null, $name=null, $value=null)
	{
		parent::__construct($label, $name, $value);
	}

	/**
	 * Set the pivot source
	 * @return \App\Form\Input\FormulaTextarea
	 */
	public function setPivot($pivot)
	{
		$this->pivot = $pivot;

		return $this;
	}

	/**
	 * (non-PHPdoc)
	 * @see \Engine\Form\Input\Autocomplete::getUrl()
	 */
	public function getUrl()
	{
		return \Engine\Mvc\Dispatcher::getInstance()->getAppUrl('Modules/RemoteData/AutocompleteFormula', '', ['pivot'=>$this->pivot] );
	}

	/**
	 * Returns a list of collected parameters used in the html template
	 *
	 */
	protected function getTemplateParams($templateClass = null, $parentElement = null)
	{
		$params = parent::getTemplateParams($templateClass, $parentElement);
		$params['pivot'] = $this->pivot;

		$params['url'] = $this->getUrl();

		return $params;
	}
}
