<p>I’m having an issue with resaving a matrix block on users from a front end form. The problem is that after resaving the block and the page reloading. The styling on the page breaks until reload.  When opening the web console, a number of errors are returned that I’m pretty sure shouldn’t be in the front end:</p>

<p><img src="https://i.sstatic.net/NJLnU.png" alt="Imgur: web console errors"></p>

<p>I think I may have found the code in the craftcms vendor files that is causing this to happen. It is located in craftcms/cms/src/elements/MatrixBlock.php</p>

<p>Commenting out the following code seems to stop all of the errors and on reload the page is fine:</p>

<pre><code>/**
 * @inheritdoc
 */
public function afterDelete()
{

    if (!Craft::$app-&gt;getRequest()-&gt;getIsConsoleRequest()) {
        // Tell the browser to forget about this block
        $session = Craft::$app-&gt;getSession();
        $session-&gt;addAssetBundleFlash(MatrixAsset::class);
        $session-&gt;addJsFlash('Craft.MatrixInput.forgetCollapsedBlockId('.$this-&gt;id.');');
    }

    parent::afterDelete();
}
</code></pre>

<p>Apart from this, I can’t seem to get any further into cracking the issue. Does anyone have any ideas? Thanks.</p>

CC BY-SA 3.0
2018-04-19T15:30:57.493Z
I have exactly the same problem. Using Matrix within SuperTable.
r-ninja
CC BY-SA 3.0
2018-04-24T20:28:03.770Z
This should now be fixed thanks to [this fix](https://github.com/craftcms/cms/pull/2799) in 3.0.4
Harry Harrison
<matrix><craft3><frontend-form>
Craft 3 - Resaving Matrix from frontend causing issues (Craft is not defined)
# Craft 3 - Resaving Matrix from frontend causing issues (Craft is not defined)

(Asked by: username_0 on 2018-04-12)

I’m having an issue with resaving a matrix block on users from a front end form. The problem is that after resaving the block and the page reloading. The styling on the page breaks until reload.  When opening the web console, a number of errors are returned that I’m pretty sure shouldn’t be in the front end:

I think I may have found the code in the craftcms vendor files that is causing this to happen. It is located in craftcms/cms/src/elements/MatrixBlock.php
Commenting out the following code seems to stop all of the errors and on reload the page is fine:
/**
 * @inheritdoc
 */
public function afterDelete()
{

    if (!Craft::$app->getRequest()->getIsConsoleRequest()) {
        // Tell the browser to forget about this block
        $session = Craft::$app->getSession();
        $session->addAssetBundleFlash(MatrixAsset::class);
        $session->addJsFlash('Craft.MatrixInput.forgetCollapsedBlockId('.$this->id.');');
    }

    parent::afterDelete();
}

Apart from this, I can’t seem to get any further into cracking the issue. Does anyone have any ideas? Thanks.

**Tags:** matrix, craft3, frontend-form

> **Comments:**
> **username_1**: I have exactly the same problem. Using Matrix within SuperTable.  
> **username_2**: This should now be fixed thanks to [this fix](https://github.com/craftcms/cms/pull/2799) in 3.0.4  

---

## 0 answers

