bmacnaughton

Pages::saved hook called even when failure

1 post in this topic

I have a hook that creates a page for a subset of the pages on our site. It uses the saved page's name as part of the created page's name.

The problem I am having is that my hook, attached to Pages::saved(), is being called even when the page save failed because of missing fields. Is there a way I can tell that the page save failed due to missing fields?

 

Never mind - it does succeed; it just issues warnings about required fields.

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bmacnaughton
      When I delete a page name, e.g, /cart/, using the admin interface it goes into trash and gets the name /trash/2573.1.11_cart/ .
      I see that, with the Pages::trashed hook that the previous page name (previousPage) can be accessed.
      Where can I more information about what happens when a page is put into trash and what the name means?
    • By gebeer
      Hello,
      I noticed that the Pages::added hook gets called twice. PW 3.0.62.
      To test , add this to admin.php
      wire()->addHookAfter('Pages::added', function($event) { bardump('added'); // needs Tracy Debugger }); Can anyone confirm this?
      It gives me trouble when adding a hook that skips the page add step (for users), following Pete's concept. There will always be created 2 new pages which I need to avoid.
      Is it a feature or a bug?
       
    • By Harmen
      Hi folks,
       
      On the website I am working on I do have a form which needs to be filled in (duh) and when the user clicks on download, the data is send with ajax and processed in the same file by using the ProcessWire API with $config->ajax;
      The data which is provided by the user will be checked with data in my database. If the data is correct I want to push a file download. But this is not working at the moment. It seems like the content of the (.exe) file is pasted in the console instead of pushing the file. My code looks like this:
      if ($config->ajax){ $serial = $input->post('serial'); $DB = DB(); $query = $DB->prepare("/*My query here*/"); $query->bindParam("comparision", $serial, PDO::PARAM_STR); $query->execute(); $reply = ''; $SN_rows = $query->rowCount(); if (!$SN_rows > 0) { $reply = 'error'; } else { $reply = 'success'; $installer = $page->attachments->eq(1); $filename = "Filename"; $filepath = $installer->filename; $options = array( 'forceDownload' => true, 'exit' => true, 'downloadFilename' => $filename ); wireSendFile($filepath, $options); } echo $reply; exit(); } What am I doing wrong here or is it a bug? Is there another way to do this with the processwire API?
       
      Thanks in advance,
       
      ~Harmen
    • By nbcommunication
      Hi,
      I'm sure this is maybe in the works already, given that findMany() is a recent addition to the API, but having this (and the other new find options) available to $users would be a great addition.
      Cheers,
      Chris
      NB Communication