I have implemented the auto complete functionality using the Ajax.autocompleter function of the Scriptaculous js framework. The code is working, but I get the entire list populated instead of populating only the entries that match with the letter I have specified. This is my code:
This is the js function to get the auto-suggested entries.
new Ajax.Autocompleter("autocomplete", "autocomplete_choices",
"http://localhost/FormBuilder/forms/autoComplete",{});
This is the auto complete box and the entries where the entries are populated.
<input type="text" id="autocomplete" name="autocomplete_parameter"/>
<div id="autocomplete_choices" class="autocomplete"></div>
And this is the autoComplete action in the forms controller where get the list of users corresponding to the typed letter.
function autoComplete()
{
$this->set('users',$this->User->find('all',array('fields'=>array('User.id','User.name'),
'conditions'=>array('User.name LIKE' => $this->data['User']['name'].'%')
)
)
);
$this->layout = "ajax";
}
But suppose if I type letter 'p', I get the entire user's list instead of displaying the ones starting with the letter 'p'. Why do I get this problem? Where have I gone wrong?