Hi, I have an auto complete box which is populated with the list of users of the application. It is working fine with the box listing the users.
But I am able to select only one user. How to select multiple users from the list ? And also how to save the selected user's names in a variable or an array?
EDIT
I am using the built-in auto complete feature of the CakePHP framework. This is the action in the controller which generates the auto complete text box.
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";
}
This is the auto_complete.ctp file
<ul>
<?php foreach($users as $user): ?>
<li><?php echo $user['User']['name']; ?></li>
<?php endforeach; ?>
</ul>
And this is the view where I have the auto complete box:
<?php echo $form->create('User', array('url' => '/forms/share')); ?>
<?php echo $ajax->autoComplete('User.name', '/forms/autoComplete');?>
<?php echo $form->end('Share');?>
In the auto complete box, I am able to select only one user name. how can I select multiple users with a comma or space separator?