cakephp-datatable icon indicating copy to clipboard operation
cakephp-datatable copied to clipboard

Getting error with nested Containable

Open AshHimself opened this issue 10 years ago • 4 comments

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 avatar Oct 30 '14 13:10 AshHimself

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

AshHimself avatar Oct 30 '14 14:10 AshHimself

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 avatar Oct 30 '14 14:10 cnizzardini

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

fr0z3nfyr avatar Oct 14 '16 06:10 fr0z3nfyr

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

shawnm0705 avatar Jan 02 '17 06:01 shawnm0705