Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom PK->FK association #33

Open
OmgDef opened this issue Feb 23, 2014 · 0 comments
Open

Custom PK->FK association #33

OmgDef opened this issue Feb 23, 2014 · 0 comments

Comments

@OmgDef
Copy link

OmgDef commented Feb 23, 2014

I have a problem with saving related model.

Order model :

            'customer' => array(self::HAS_ONE, 'Customer', array('id' => 'customer_id')),

Customer model:

            'orders' => array(self::HAS_MANY, 'Order', 'customer_id'),

Controller:

        if (isset($_POST['Order'])) {
            $model->attributes = $_POST['Order'];
            if (isset($_POST['Customer']))
                $model->customer->setAttributes($_POST['Customer']);

            if ($model->withRelated->save(true, array('customer')))
                $this->redirect(array('admin'));
        }

After save customer_id property of Order is NULL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant