Jump to content

Hook: Check field data and prevent page from being saved


Susticle
 Share

Recommended Posts

Hello everybody,

I'm doing websites with Processwire for some time now. Now there is the first time I need to setup a hook.

I created a module, that was no problem. I added a hook:

Quote

$this->pages->addHookbefore('save', $this, 'checkMethod');

In checkMethod I can check for errors and give out an error message with $this->error. With event->replace in case of errors I can prevent saving the wrong data. Everything's fine.

But still I get the message that the page has been saved. So I think I did something wrong.

What's the correct way to add a hook that checks the data, gives out an error message and prevents the page from being saved?

Thanks,
Lars

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...