hey any idea why patchEntity cant work with my data properly?
$requestDatanew = [
'title' => $requestData['title'] ?? null,
'body' => $requestData['body'] ?? null,
];
$article = $this->Articles->patchEntity($article, $requestDatanew, [
'validate' => 'edit',
'accessibleFields' => array_fill_keys(array_keys($requestDatanew), true)
]);
also not with an assassociated table…
if (isset($requestData['farms'])) {
$requestDatanew['farms'] = [];
foreach ($requestData['farms'] as $key => $farm) {
$requestDatanew['farms'][$key] = [
'id' => $farm['id'] ?? null,
'active' => $farm['active'] ?? null,
'title' => $farm['title'] ?? null,
];
}
}
$article = $this->Articles->patchEntity($article, $requestDatanew, [
'validate' => 'editc',
'associated' => [
'Farms' => [
'accessibleFields' => array_fill_keys(array_keys($requestDatanew['farms'][0] ?? []), true)
]
]
]);
idea? best,