Skip to content

Custom PK->FK association #33

@OmgDef

Description

@OmgDef

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions