I got it!  Answer by myself....

1. config the routes.php
add   $Route->connect('/*/add/*', array('controller' => 'users',
'action'=> 'add'));

2. add new function in the users_controller.php
function add($username)
{
        $user = $this->User->findByUsername($username);
        $this->set('user', $user);

        if (!empty($this->data))
    {
        $this->data['Topic']['username']=$username;
        $this->User->Topic->save($this->data);
        {
        $this->_message('Topic saved.',  '/'.$user['User']['username'].'/');
         }
    }
//check the manul abou the Association-Saving models.

3.config the views/users/add.thtml

<form action="<?php echo
$html->url('/'.$user['User']['username'].'/add'); ?>" method="post">
<div class="optional">

        <?php echo $form->labelTag('Topic/name', 'Name');?>
        <?php echo $html->input('Topic/name', array('size' => '60'));?>
        <?php echo $html->hidden('Topic/user_id', array('size' =>
'60','value'=>$user['User']['id']));?>
        <?php echo $html->tagErrorMsg('Topic/name', 'Please enter the
Name.');?>
</div>
<div class="submit">
        <?php echo $html->submit('Add');?>
</div>
</form>

P.S.
To clear abou the Model User and Topic
<?php pr($user)?>
To know the relation and the whole structure.

Loving Cake!!


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to