fix: [component:CRUD] Fix edit where query parameters where not passed correctly
It fixes meta-fields duplication while savingpull/93/head
parent
b30dff219b
commit
a9570426db
|
@ -454,18 +454,24 @@ class CRUDComponent extends Component
|
||||||
$params['contain'][] = 'Tags';
|
$params['contain'][] = 'Tags';
|
||||||
$this->setAllTags();
|
$this->setAllTags();
|
||||||
}
|
}
|
||||||
$queryParam = isset($params['get']) ? $params['get'] : $params;
|
$params = isset($params['get']) ? $params['get'] : $params;
|
||||||
if ($this->metaFieldsSupported()) {
|
if ($this->metaFieldsSupported()) {
|
||||||
if (empty( $queryParam['contain'])) {
|
if (empty($params['contain'])) {
|
||||||
$queryParam['contain'] = [];
|
$params['contain'] = [];
|
||||||
}
|
}
|
||||||
if (is_array( $queryParam['contain'])) {
|
if (is_array($params['contain'])) {
|
||||||
$queryParam['contain'][] = 'MetaFields';
|
$params['contain'][] = 'MetaFields';
|
||||||
} else {
|
} else {
|
||||||
$queryParam['contain'] = [ $queryParam['contain'], 'MetaFields'];
|
$params['contain'] = [$params['contain'], 'MetaFields'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query = $this->Table->find()->where(['id' => $id]);
|
$query = $this->Table->find()->where(['id' => $id]);
|
||||||
|
if (!empty($params['get'])) {
|
||||||
|
$query->select($params['get']);
|
||||||
|
}
|
||||||
|
if (!empty($params['contain'])) {
|
||||||
|
$query->contain($params['contain']);
|
||||||
|
}
|
||||||
if (!empty($params['conditions'])) {
|
if (!empty($params['conditions'])) {
|
||||||
$query->where($params['conditions']);
|
$query->where($params['conditions']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue