Jump to content

Validate pages


wumbo
 Share

Recommended Posts

Hi folks!

I'm currently using the Pages::__save() hook within a custom module to inform an external service that a page was saved. Now I only need to inform the external service if a valid page was saved (no field validation errors occurred). ProcessWire saves the page (even published pages) regardless of any field validation errors (e.g. missing input for a required field).

Is their any way of validating a page instance within my module? Something like $myPage->isValid()?

It would also help if someone could point me to the relevant lines of source code where the ProcessWire editor validates page input on saving.

Regards,

Marco

  • Like 1
Link to comment
Share on other sites

Validation does not happen on the page level, but in each fieldtype separately and also technically this doesn't happen when a page is saved, but rather right when new values are set to the field regardless of what happens afterwards. So I doubt there's a reliable way to check if the whole page's changes where all validated. Maybe you can check, if the ProcessPageEdit form, that you're using in the backend, validated completely, but that does leave out any changes elsewhere.

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

×
×
  • Create New...