Jump to content

Strange behaviour why hook is not working


Juergen
 Share

Recommended Posts

Hello,

I have a hook which should copy the value of one field to another on special type of templates:

$pages->addHookBefore('saveReady', function($event)
{
    $page = $event->arguments(0);
    $page->setOutputFormatting(false);
        if(in_array($page->template->name, array('event_specialbusinesshours', 'single-special-business-hours'))) {
           $page->endeventdate = $page->starteventdate;
        }
});

The field value will be copied -> this works. The 2 fields are requiered. After pressing the save button I got the following message that the value is missing, but it is still there

screenshot-www.juergen-kern.at-2017-10-29-08-18-51.png.4e6a36b4c7612cc48658e0a9382d69a5.png

To eliminate this error I could set the second field to not required, but I want an explanation why a copied value with "hook before saveready" leads to such an error-message. Does the validation take place before this hook. If yes, which hook method should be used instead?

Best regards

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