Jump to content
Susticle

Hook: Check field data and prevent page from being saved

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

Share this post


Link to post
Share on other sites

Hook into Pages::saveReady instead and throw error inside checkMethod()

  • Thanks 1

Share this post


Link to post
Share on other sites
On 10/31/2017 at 3:40 PM, abdus said:

Hook into Pages::saveReady instead and throw error inside checkMethod()

Thank you very much!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...