Grant Cox wrote:
> A hasOne B       means that B has a B.A_id
> A belongsTo B    means that A has a A.B_id
>
> So from what I understand of your associations, you want Judge
> belongsTo Person.

Thanks!  I got it working fine for read operations, but not for
writing, Here's what I mean:

Judge model:

class Judge extends AppModel {

        var $name = 'Judge';
        var $belongsTo = 'Person'
        var $primaryKey = 'person_id';
}


In my JudgesController class, I have

function index()
        {
                $this->set('judges',$this->Judge->findAll());
        }

and it works fine. However, in my edit(), I find that

     $this->Judge->save($this->data)

only updates the judges table, not the people table (its parent, which
it belongsTo). Here's my edit() method from JudgesController:

        function edit($id = null) {

                if (empty($this->data)) {

                        $this->Judge->Person_id = $id;
                        $this->data = $this->Judge->read();

                } else {

                        if (
                                $this->Judge->save($this->data)
                               // && $this->Person->save($this->data)
                        )
                        {
                                $this->flash('Your judge has been 
updated.','/judges/');
                        }
                }
        }
}

I might add that in my edit.thtml I have hidden fields like so:
<?php echo $html->hidden('Judge/person_id'); ?>
<?php echo $html->hidden('Person/id'); ?>

The hack that I've been doing is instantiating a Person and assigning
it to an instance var in my constructor, then manually updating it in
edit() as you can see in the line that's commented out above.

I doubt that I am doing this right. Anybody have idea what I am doing
wrong?

Many TIA.


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

Reply via email to