CMS Page edit

When an Edit Page in CMS is loaded, it already showing that something is changed and the class of Save button and form is changed. Indicating that something has changed even if it just loaded.

I noticed that when I remove the “$this->beforeUpdateCMSFields” call in getCMSFields of the Page, the issue disappears. Any idea why is it happening?

This usually means a form field has changed after the form has loaded into the DOM, which would suggest that there’s some javascript being added in your $this->beforeUpdateCMSFields() call which is altering the value of some form field.

Without knowing what’s happening in that call, it’s hard to provide any specific help. Can you please post a snippet showing what’s happening there?

In this case, when you say

do you mean you remove everything within that callback as well? Or do you keep all of that (e.g. $fields->removeByName('Categories');) and just don’t pass it as a callback to beforeUpdateCMSFields()?

I mean I remove everything in the callback as well.

Okay. I recommend narrowing down to find out what specifically is causing this by removing pieces of code one at a time.

Start by removing the call to beforeUpdateCMSFields() but keep everything from within the callback. If it’s still happening, don’t remove the Categories field. Then try not changing the gridfield config, etc.

Once you know specifically what is causing this, it will be easier to determine if there’s an actual bug here or just an unintentional side-effect to something in your own code.

1 Like