Jump to content

Validating: Start year <= End year


Recommended Posts

The easiest way would probably be to use hooks in ready.php - something like the pseudo-code below:

$pages->addHookBefore('Pages::saveReady', function(HookEvent $event) {
  $page = $event->arguments(0);

  // todo: change template name
  if($page->template == "your-template" { 

    // todo: change field names
	$field1 = $page->dateStart;
    $field2 = $page->dateEnd;

	// todo: add validation
    if($field1 > $field2) {
		// show a message
		// whatever
    }
  }
});

This would hook into the save process just before the page would be saved. Therefore you could check if the fields validate.

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