I have an entry with a matrix field which I'm updating from front-end. The update works fine, but when the (font-end) page reloads after submitting the form, the CP bundle assets get included (selectize.css, craft.css, charts.css). If I then reload the page, the CP assets are no longer included. I believe have narrowed it down to the use of $entry->setFieldValue(). Does anyone know why that's happening and how to stop it? Or is there a different way to update an entry with a matrix field from font-end that doesn't require me to use setFieldValue()?
Here's the relevant part of my update function:
$field = Craft::$app->getFields()->getFieldByHandle('fieldHandle');
$existingMatrixQuery = $entry->getFieldValue('fieldHandle');
$serializedMatrix = $field->serializeValue($existingMatrixQuery, $entry);
$serializedMatrix['new1'] = [
'type' => 'update',
'enabled' => 1,
'collapsed' => true,
'fields' => array_merge($params['fields'], $params['required'])
];
$entry->setFieldValue('fieldHandle', $serializedMatrix);
if (Craft::$app->getElements()->saveElement($entry)) {
return true;
}