I had a search and couldn't find anything explicit with the current
version so I thought I'd ask.

I have a 'users' and 'companies' model:

class User extends AppModel {
        var $name = 'User';
        var $belongsTo = array('Group','Company');
        var $recursive = 3;
}

class Company extends AppModel
{
        var $name = 'Company';
        var $hasMany = 'User';
}

I have a form in a view /companies/add_company/ which has both company
information, and user information on it which I want to save down at
the same time.

In my 'Companies' controller:

function add_company()
{
        if (!empty ($this->params['data'])) {
                if ($this->Company->save($this->params['data'])) {
                        $this->set('data', $this->Company->findAll());
                        $this->render('index', 'ajax');
                } else {
                        // do nothing
                }
        }
        $this->autoLayout = NULL;
}

This saves the company information correctly but of course the user
information is not.  Do I need to reformat the params['data'] to
something like:

$this->arrCompany['data'] = $this->params['data']['Company'];
$this->arrUser['data'] = $this->params['data'][User'];

then save:

$this->Company->save($this->arrCompany['data']))
$this->User>save($this->arrUser['data']))

?


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