Jump to content

Redeeming page field's preexisting value in saveReady hook


hellomoto
 Share

Recommended Posts

	function customPageSaver(HookEvent $hook) {
	 	$page = $hook->arguments(0);
	 	if ($page->template->name == 'event_instance' && $page->id !== 0) {
			$page->setOutputFormatting(false);
			$page->name = wire()->sanitizer->pageName(wireDate('Y-m-d', $page->date));

			if ($page->time_end < $page->time_start) {
				$hook->message('End AFTER starting.');
				$page->time_end = '';
			}
	 	}
	}
    $this->addHookAfter('Pages::saveReady(template=event_instance)', null, 'customPageSaver');

-- site/ready.php

Can I set the $page->time_end to its previous value, rather than ''? I think I've done that before but forget how.

Link to comment
Share on other sites

16 hours ago, hellomoto said:

Can I set the $page->time_end to its previous value, rather than ''? I think I've done that before but forget how.

This old thread should get you started. However, I am not sure how you would be able to get the current value of the start time to compare against. 

 

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