-
- 620 Posts
Looking for options to validate a TV against another TV (is strat date before end date) before a user saves a resource. Are there extras or manager tools to do this or am I stuck writing a plugin?
*** Not just websites, we also create signage, banners, print, trade show displays and more! ***
Sean Kimball CLP, CLS.
Technical Director / Sr. Developer | BigBlock Studios
._______________________________________________.
Bigblock Studios
http://www.bigblockstudios.ca Web site design & development.
27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
phone/fax: 905-426-5525
-
- 293 Posts
I think that would need to be a plugin. It should be quite straight forward though providing you've got the resource ids and TV names that you need.
-
- 24,544 Posts
I think it might be simple as something like this, connected to OnBeforeDocFormSave:
$start = strtotime($resource->getTVValue('start_date'));
$end = strtotime($resource->getTVValue('end_date'));
if ((!empty($start)) && (!empty($end)))
if ($end < $start) {
return (array('End date must be later than start date'));
}
}
return;
It should display the error message, but I've never tested it.
This will check both new and existing resources on save. If you don't want that, you can put something like this at the top:
if ($mode === modSystemEvent::MODE_NEW) {
return '';
}
You may also want to add a test of $resource->get('parent') or $resource->get('id') at the top to limit it to specific resources.
-
- 620 Posts
Quote from: BobRay at Feb 12, 2019, 07:08 PMI think it might be simple as something like this, connected to OnBeforeDocFormSave:
$start = strtotime($resource->getTVValue('start_date'));
$end = strtotime($resource->getTVValue('end_date'));
if ((!empty($start)) && (!empty($end)))
if ($end < $start) {
return (array('End date must be later than start date'));
}
}
return;
It should display the error message, but I've never tested it.
This will check both new and existing resources on save. If you don't want that, you can put something like this at the top:
if ($mode === modSystemEvent::MODE_NEW) {
return '';
}
You may also want to add a test of $resource->get('parent') or $resource->get('id') at the top to limit it to specific resources.
thanks Bob - ya - it looks good.
*** Not just websites, we also create signage, banners, print, trade show displays and more! ***
Sean Kimball CLP, CLS.
Technical Director / Sr. Developer | BigBlock Studios
._______________________________________________.
Bigblock Studios
http://www.bigblockstudios.ca Web site design & development.
27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
phone/fax: 905-426-5525
-
- 24,544 Posts
Don't thank me until it works.