Jump to content

Problem with isChanged/getChanges and textarea field


saleo
 Share

Recommended Posts

Hello. I'm trying to track the changes of a textarea field. The field has a TinyMce inputifeld configured and Markup/Html as content type. To track the changes I use this hook in the init.php:

wire()->addHookBefore('Pages::saveReady', function($event) {
        $page = $event->arguments(0);
        if($page->template->name === 'wiki-page'){
            if($page->isChanged('body')){
                bd($page->getChanges()); //using Tracy here
            }
        }
    });

The issue is that the isChanged method returns ['body'] even if the body field has not changed, but only when some type of markup is present.

For example, if I put some simple formatted text and I save the page, the changes are tracked correctly. But if I put a <table> or a <ol> in the body, when I save the page the isChanged method returns always ['body'], even if I have not changed anything.

Am I doing something wrong with the hook? Maybe the saveReady is not the correct place to track changes? Or is this a Processwire issue?

I'm using Processwire 3.0.227, the only extra plugins installed are ProcessDatabaseBackups and TracyDebugger, and I'm using php 8.2.4 in a Mamp Pro installation on MacOs.

Thank you!

Leo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...