Is there a reason why you are doing two separate saves? COuld you not create a 
well formed data array and do a saveAll?

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 2 Sep 2010, at 18:26, hvannia wrote:

> Hi,
> Basically I Have a HATBM between "A" and "B" tables,
> at the "A" controller, once the data for "A" has been entered I want
> to save "A" and "A_B" tables .
> 
> I read  the " How to add item using HABTM relation " disussion but
> still cant get it done.
> 
> This is what i got so far:
> 
> // within "A" controller:
> 
> function add() {
>               if (!empty($this->data)) {
>                       $BId=$this->Session->read('BId');
>                       $this->A->create();
>                       if ($this->A->save($this->data)) {
>                              $lastCreated=$this->A->find('first',
> array('conditions' => array('A.name' => $this->data['A']['name']),
> 'fields'=>'id'));
>                                $this->set('Bid',$BId);
>                               $this->set('Aid',$lastCreated['A']['id']);
>               }
> 
> // within "A" view
> 
> echo $this->Form->input('A_B.A_id', array('type'=>'hidden' , 'value'=>
> $AId));
> echo $this->Form->input('A_B.B_id', array('type'=>'hidden' , 'value'=>
> $BId));
> 
> ...
> 
> thanks
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to