Hello,

I am learning CakePHP and now using Cake 1.3. I have a worked auto
complete. I follow the instruction in the manual. The problem is, I'd
like to take id from auto complete's data. What should I do, since
what i need is the id from the autocomplete's data (I need to insert
it to database)?

##########################
autoComplete()
##########################

function autoComplete(){
            $this->set('groups', $this->User->Group->find('all', array(
                'conditions' => array(
                                                'Group.name LIKE' => 
$this->data['Group']['name'].'%'
                                                ),
                'fields' => array('name', 'id')
                )));
                $this->layout = 'ajax';
        }


##########################
auto_complete.ctp
##########################

<ul>
<?php foreach($groups as $group): ?>
<li>
<?php
echo $group['Group']['id'].'-'.$group['Group']['name'];
?>
 </li>
<?php endforeach; ?>
</ul>



##########################
add.ctp
##########################

<fieldset>
                <legend><?php __('Add User'); ?></legend>
        <?php
                echo $this->Form->input('username');
                echo $this->Form->input('password');
                echo __('Group');
                echo $ajax->autoComplete('Group.name', '/users/autoComplete');
        ?>
        
        </fieldset>


/** code end **/


I apologize, if my English is poor enough.
Thank you for any responses. I'll appreciate it.

-- 
Regards,,,
mastanto
http://www.mastanto.com

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to