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

		$data = [];
		$query = $this->_controller->request->data('query');
		$target = (array)$this->_controller->request->data('target');
		$limit = $this->_modelConfigSearchInfo->getAutocompleteLimit();
		$data = $this->_modelSearch->getAutocomplete($query, $target, $limit);

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

		$data = [];
		$query = $this->_controller->request->data('query');
		$target = (array)$this->_controller->request->data('target');
		$limit = $this->_modelConfigSearchInfo->getAutocompleteLimit();
		$data = $this->_modelSearch->getAutocomplete($query, $target, $limit);

		$this->_controller->set(compact('data'));
		$this->_controller->set('_serialize', 'data');
	}
public function autocomplete ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> _controller -> request -> is ( 'ajax' ) || ! $ this -> _controller -> request -> is ( 'post' ) || ! $ this -> _controller -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ ] ; $ query = $ this -> _controller -> request -> data ( 'query' ) ; $ target = ( array ) $ this -> _controller -> request -> data ( 'target' ) ; $ limit = $ this -> _modelConfigSearchInfo -> getAutocompleteLimit ( ) ; $ data = $ this -> _modelSearch -> getAutocomplete ( $ query , $ target , $ limit ) ; $ this -> _controller -> set ( compact ( 'data' ) ) ; $ this -> _controller -> set ( '_serialize' , 'data' ) ; }
Action `autocomplete`. Used to autocomplte input fields.

POST Data:
- `query` query string for autocomple;
- `target` target field for autocomple;

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