Hi at all,
I have this problem:
I have ad assistance model that have a belongsTo relation with another
model called client.
So i want to utilize ajax autocomplete to substitute the classic
select field generated by the FORM helper fot the client_id.
So I want that aoutocomplete search in the client table and show me
the name of the client, but when I select one of this I want that del
client_id is filled by the relative ID of the client.
I think that utilizing a hidden field is the solution, but I don't
know howto make the work.
For now I have prepared the autocompelte function like the examples in
the book.cakephp.org
in the assistance controller:
function autoComplete() {
$this->set('clients', $this->Assistance->Client->find('all',
array
('conditions' => array('Client.name LIKE' => $this->data['Client']
['name'].'%'),'fields' => array
('id','name','Cellulare'),'order'=>'Client.name ASC')));
$this->layout = 'ajax';
}
I have made the autocomplete.ctp
<ul>
<?php foreach($clients as $client): ?>
<li><?php echo $client['Client']['name']; ?></li>
<?php endforeach; ?>
</ul>
and in the view:
echo $ajax->autoComplete('Client.name', '/clients/autoComplete',array
('label' => 'Nome e Cognome Cliente'));
Does anyone suggest me how to monitor the change of that field, and
fill the correct idden field with the id?
Best Regards
Franco Tampieri
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---