views:

23

answers:

1

Hi All,

I have a problem related to the function "SaveAll" in cakephp 1.2+ as the following:

I have 3 models: A, B, C that the relation is:

A belongTo B

B hasOne A

B belongTo C

C hasOne B

Above it means A,B,C all relation is 1-1

I have a form that includes all field of A,B,C to create new A,B,C. When saving, I can't create new A,B,C with the function SaveAll because when checking sql log of cake, the function SaveAll doesn't generate INSERT sql for model C

Pls help me resolve this problem ?

A: 

index.ctp

       <?php echo $form->create('Customer',array('action' => 'customers/add'));
echo $form->input('Customer.name');
echo $form->radio('CustomerReview.comment');
echo $form->radio('CustomerRating.value');
?>

in customers_controller.php file

    class CustomersController extends AppController {
    var $name = 'Customers';

    function index(){

        $this->layout = 'site';

        if(!empty($this->data)){
            if($this->Customer->saveAll($this->data)){
                $this->Session->setFlash('Thank you for the feedback!');
            }
        }
    }
}

here Customer = A CustomerReview = B CustomerRating = C

RSK
could you send me content of 3 models: Customer = A CustomerReview = B CustomerRating = C ?
dr.king
your examples I think that A relates to B and A relates to C. But I need saveAll when A relates to B and B relates to C.
dr.king