Validating 2 fields

Hi folks,

I have two fields setup in a collection


How can I validate the second date (Unpublish) to be after the first date (Publish)?


You could have a script listen for this trigger

# /modules/Collections/bootstrap.php:401
$this->app->trigger('', [$name, &$entry, $isUpdate]);

It will allow you to update the data for the to-be-saved $entry.
This means you could enforce at that point that unpublish_date must be >= publish_date.

You could put this script into /config/bootstrap.php

An alternative would be to use the WRITE rule for this particular collection.
It allows you to access the following object via the variable $context:

                'options' => $options,
                'entry'   => $entry

As you can see it also contains the to-be-written $entry data, that again, can be adjusted.