public function autocomplete() {
		Configure::write('debug', 0);
		if (!$this->request->is('ajax') || !$this->request->is('post') ||
			!$this->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [];
		$query = $this->request->data('query');
		if (empty($query)) {
			$this->set(compact('data'));
			$this->set('_serialize', 'data');

			return;
		}

		$type = $this->request->data('type');
		$plugin = $this->request->data('plugin');
		$limit = $this->ConfigTheme->getAutocompleteLimitConfig();
		$data = $this->Filter->getAutocomplete($query, $type, $plugin, $limit);
		if (empty($data)) {
			$data = [];
		}

		$this->set(compact('data'));
		$this->set('_serialize', 'data');
	}
public function autocomplete() {
		Configure::write('debug', 0);
		if (!$this->request->is('ajax') || !$this->request->is('post') ||
			!$this->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [];
		$query = $this->request->data('query');
		if (empty($query)) {
			$this->set(compact('data'));
			$this->set('_serialize', 'data');

			return;
		}

		$type = $this->request->data('type');
		$plugin = $this->request->data('plugin');
		$limit = $this->ConfigTheme->getAutocompleteLimitConfig();
		$data = $this->Filter->getAutocomplete($query, $type, $plugin, $limit);
		if (empty($data)) {
			$data = [];
		}

		$this->set(compact('data'));
		$this->set('_serialize', 'data');
	}
public function autocomplete ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ ] ; $ query = $ this -> request -> data ( 'query' ) ; if ( empty ( $ query ) ) { $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; return ; } $ type = $ this -> request -> data ( 'type' ) ; $ plugin = $ this -> request -> data ( 'plugin' ) ; $ limit = $ this -> ConfigTheme -> getAutocompleteLimitConfig ( ) ; $ data = $ this -> Filter -> getAutocomplete ( $ query , $ type , $ plugin , $ limit ) ; if ( empty ( $ data ) ) { $ data = [ ] ; } $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action `autocomplete`. Is used to autocomplte input fields.

POST Data:
- `query`: query string for autocomple.
- `type`: type for autocomplete suggestions, e.g. Model.Field.
- `plugin`: plugin name for autocomplete field.

@throws BadRequestException if request is not `AJAX`, or not `POST`
or not `JSON`
@return void
Action autocomplete . Is used to autocomplte input fields .