hi,
I am trying to only update the tags._joinData.quantity
field. But I am unable to set the patchEntity to only allow that field.
$formData = $this->request->getData();
// Test inject
$formData['title'] = 'This should not be edited ' . date('h:i:s');
$formData['tags'][0]['description'] = 'This should not be edited ' . date('h:i:s');
$article = $this->Articles->patchEntity($article, $formData, [
'fields' => [ '*' => false, ],
'associated' => [
'Tags' =>
[
'description' => false,
'_joinData' => ['fields' => ['quantity']],
// does not work too
// '_joinData' => [
// 'accessibleFields' => ['description' => false, 'quantity' => true]
// ]
]
],
]);
$article->setDirty('tags');
$this->Articles->save($article);
In the code above,
-
title
field is not patched/updated because of the'*' => false
condition. Not sure whether this is the right way as I don’t see any document on this. -
quantity
field is updated together with thedescription
field.
The problem is I don’t want any other fields to be updated except quantity
field in the _joinData.