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;

1 Answer 1


Turns our it was this line causing the issue:

'collapsed' => true,

Removed it and all works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.