Skip to content

Instantly share code, notes, and snippets.

@taleeb35
Created September 19, 2014 12:57
Show Gist options
  • Select an option

  • Save taleeb35/f96d0c64a85006ec3bae to your computer and use it in GitHub Desktop.

Select an option

Save taleeb35/f96d0c64a85006ec3bae to your computer and use it in GitHub Desktop.
public function find() {
if ($this->request->is('ajax')) {
$this->autoRender = false;
$country_name = $this->request->data['Country']['name'];
$results = $this->Country->find('all', array(
'conditions' => array('Country.name LIKE ' => '%' . $country_name . '%'),
'recursive' => -1
));
$resultArr = array();
foreach($results as $result) {
$resultArr[] = array('label' =>$result['Country']['name'] , 'value' => $result['Country']['name'] );
}
echo json_encode($resultArr);
//exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment