<?php

namespace App\Form\Input;

/**
 * City autocomplete field
 *
 */
class Autocomplete_City extends Autocomplete_GeneralAbstract
{

	protected $class = "autocompleteCity";

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

		$this->setStyle('minimumTextLength', 1);
	}

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

	/**
	 * (non-PHPdoc)
	 * @see \Engine\Form\Input\Autocomplete::determineDisplayValue()
	 */
	public function determineDisplayValue($displayId) :string
	{
		return (string)\Entity\City::select($displayId)->name;
	}

}
