class EnvoicesController extends AppController {
var $name='Envoices';
var $helpers= array('Form','Html','Ajax','Javascript','Time',
'Paginator');
var $scaffold;
function index(){
$this->render('autocomplete');
}
function autocomplete(){
$this->set('clients',$this->Envoice->Client-
>findAll("Client.ruc LIKE '{$this->data ['Client']['ruc']}%'",
array('Client.name','Client.ruc'),'Client.id ASC', 20));
#now render element
//$this-
>render('autocomplete','ajax','autocomplete');
$this->render('autocomplete', 'ajax','autocomplete');
}
view index.ctp
----------------------------------------------------------------------------------------------------------------
<form name="form" id="form">
<label for="user_autocomplete">Cliente:</label>
<?php echo $ajax->autocomplete('Client/name','/envoices/
autocomplete',
array('size'=>15,'frequency'=>0.2)) ?>
</form>
------------------------------------------------------------------------------------------------------------------
view autocomplete.ctp
<ul class="autocompleteList">
<?php foreach($clients as $client): ?>
<li class="autocompleteList">
<?php echo $client['Client']['name']; ?>
</li>
<?php endforeach;?>
</ul>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---