Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Getting error with nested Containable #25

Open
AshHimself opened this issue Oct 30, 2014 · 4 comments
Open

Getting error with nested Containable #25

AshHimself opened this issue Oct 30, 2014 · 4 comments

Comments

@AshHimself
Copy link

Howdy folks,

I'm getting the following error when I try to filter on a row. I can sort with no issues and data is displaying in datatable no issues but when I search I get the following error in my Ajax response.

  Warning (512): Model "Task" is not associated with model "OR" [CORE/Cake/Model/Behavio   /ContainableBehavior.php, line 342]

My action is as follows;

function getTasks() {
    $this->Task->recursive = 2;

    $this->Task->Behaviors->load('Containable');

    $this->paginate = array(
        'fields' => array('Task.id', 'Task.code', 'Task.job_id'),
        'conditions' => array(
            'Task.scheduled' => 1,
        ),
        'contain' => array(
            'Job' => array(
                'fields' => array(
                    'Job.id',
                ),
                'Site' => array(
                    'fields' => array(
                        'Site.id',
                    )
                )
            )
        )

    );

    $this->DataTable->mDataProp = true;
    $this->set('response', $this->DataTable->getResponse());
    $this->set('_serialize', 'response');
}

Thanks in advanced

@AshHimself
Copy link
Author

Just found out in documentation that deep relations in containable is not supported.

@cnizzardini
Copy link
Owner

I think the dev branch supports it. I have been busy and have not done a release. I'll check this after I get more coffee. Also, have you looked at using the Linkable behavior instead: https://github.com/dereuromark/cakephp-tools/blob/master/Model/Behavior/LinkableBehavior.php

It's much faster then containable, but it only supports one-to-one relations.

@cnizzardini cnizzardini reopened this Oct 30, 2014
@fr0z3nfyr
Copy link

Problem is not likely with deep relationship, there is a mistake in the component code. See issue #35 for solution

@shawnm0705
Copy link

I agree with @fr0z3nfyr . After I change the code, everything is fine. Good job!

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

No branches or pull requests

4 participants