Hi there!

I know, I know ... search this group an u will find the solution ...
Well, I searched, but I didn't find ...
So, maybe u can help me ...

I try to use hasAndBelongsToMany association but I'm stuck with saving
the data ...

I've got three tables ...

* locations: id, ...
* staffs: id, ...
* locations_staffs: location_id, staff_id

Staff Model:
class Staff extends AppModel {
        var $name = 'Staff';
        var $hasAndBelongsToMany = array('Location');
}

Location Model:
class Location extends AppModel {
        var $name = 'Location';
        var $hasAndBelongsToMany = array('Staff');
}

Staff Controller:
function add()
{
        $this->set('locations',$this->Staff->Location->generateList());
                if(!empty($this->data)){
                $this->Staff->save($this->data);
                pr($this->data);
        }
}

Output of pr()

Array
(
    [Location] => Array
        (
            [Location] => Array
                (
                    [0] => 2
                )
        )

    [Staff] => Array
        (
            [section] => sadfsdaf
            [firstname] => sdfsdf
            [lastname] => sdfsdf
            [email] => sdfsdf
            [phone] => sdfsdf
        )
)

I tried scaffolding and it works, so i think my naming of tables etc.
is correct.

Any ideas, why the  locations_staffs table still stays empty when I
save manualy?

Regards,
Marcus


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