This component is very limited , there is echo in component...
You can customize and create your own autocomplete stuff using this
example :
/** EXAMPLE
* Create users db table with id, username, email...
* Create user model...
**/
/**
* 1. Test controller: controller/tests.php
**/
class TestsController extends AppController
{
var $name = 'Tests';
var $uses = array('User') ;
var $helpers = array('Ajax');
function index()
{
$this->render('autocomplete');
}
function autocomplete()
{
$users = $this->User->findAll( "User.username LIKE '%{$this-
>data['User']['username']}%'", array('User.username','User.email'),
'User.username ASC', 20);
$this->set('users',$users );
#now render element
$this->render('autocomplete', 'ajax',
VIEWS.'elements'.DS.'tests'.DS.'autocomplete.thtml');
}
/**
* 2. Test view: views/tests/index.php
**/
<form name="form" id="form">
<label for="user_autocomplete">User:</label>
<?php echo $ajax->autocomplete('User/username','/tests/autocomplete',
array('minChars'=>1,'frequency'=>0.2)) ?>
</form>
/**
* 3. Autocomplete element :views/elements/tests/autocomplete.php
* U can add stuff like $user['User']['email']...here
**/
<ul class="autocompleteList">
<?php foreach($users as $user){ ?>
<li class="autocompleteList"><?php echo $user['User']['username']; ?
></li>
<?php }?>
</ul>
/**
* 4. Autocomplete css:
**/
div.auto_complete
{
position: absolute;
width: 150px;
background-color: white;
border:1px solid #888;
margin:0;
padding:0;
z-index:200;
}
div.auto_complete ul.autocompleteList {
list-style-type: none;
margin: 0px;
padding: 0px;
}
div.auto_complete ul.autocompleteList li.selected {
background-color: #ffb;
cursor: pointer;
}
div.auto_complete li.autocompleteList {
clear: none;
list-style-type: none;
display: block;
margin: 0;
padding: 2px;
height: 25px;
cursor: pointer;
}
On Apr 27, 1:46 pm, regi <[EMAIL PROTECTED]> wrote:
> hi majna...
> Thanks... now it is working... but i have got one more problem..
> the items are not listing in alphabetical order..Can you please help
> me to solve this .
>
> thanks
> Regi
>
> On Apr 27, 4:19 pm, junal <[EMAIL PROTECTED]> wrote:
>
> > hey majna....thx for this solution ...i had similar problem :)
>
> > On Apr 27, 5:17 pm, junal <[EMAIL PROTECTED]> wrote:
>
> > > thx majan ...i had similar problem .....thx for this solution :)
>
> > > On Apr 27, 4:19 pm, majna <[EMAIL PROTECTED]> wrote:
>
> > > > class AutocompleteComponent extends Object {
>
> > > > add:
> > > > var $ac_limit = 10;
> > > > var $ac_order = 10;
> > > > var $ac_fields= null;
> > > > ...
>
> > > > and:
>
> > > > $results = $controller->{$model}->findAll($conditions,$this->ac_fields,
> > > > $this->ac_order,$this->ac_limit);
>
> > > > In controller :
>
> > > > $this->Autocomplete->ac_limit=10;
>
> > > > *not tested
>
> > > > or just change this line
> > > > $results = $controller->{$model}->findAll($conditions,null,null,10);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---