cakephp-datatable
cakephp-datatable copied to clipboard
Getting error with nested Containable
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
Just found out in documentation that deep relations in containable is not supported.
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.
Problem is not likely with deep relationship, there is a mistake in the component code. See issue #35 for solution
I agree with @fr0z3nfyr . After I change the code, everything is fine. Good job!