SIERRA Posted January 20, 2024 Share Posted January 20, 2024 Hi, We have 'Seminar_Schedule' repeater field in the template (One of the Admin Control Panel Page) Inside the 'Seminar_Schedule' repeater field (parent), we have 'SS_Datetime' repeater field. Inside the 'SS_Datetime' repeater field (child), We have 'SS_Startdatetime' and 'SS_Enddatetime' fields. How to do validation for 'SS_Startdatetime' and 'SS_Enddatetime' fields for below cases. 'SS_Startdatetime' should be lesser than to 'SS_Enddatetime' 'SS_Startdatetime' should not be equal to 'SS_Enddatetime' PFA and Suggest, Link to comment Share on other sites More sharing options...
bernhard Posted January 20, 2024 Share Posted January 20, 2024 Hey @SIERRA could you please read the community rules, especially the section about "Rules for posting"? You have posted several questions over the last years and often you just disappear. It might increase your chances to get helpful answers if you try to ask in a more polite and less demanding way and at least say thank you after someone replied and tried to help in his/her spare time for free. Have a nice weekend and good luck with your project. 1 Link to comment Share on other sites More sharing options...
August Posted January 30, 2024 Share Posted January 30, 2024 Hi Sierra, that helped once me solve a similar problem .. $this->addHookAfter('InputfieldDatetime::processInput', function(HookEvent $event) { // Get the object the event occurred on, if needed $InputfieldDatetime = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; $post = $this->wire('input')->post; // change date string to timestamp $firstdate = strtotime($post->date_start); $lastdate = strtotime($post->date_end); // if first date greater than or equal to last date if ($firstdate > $lastdate && $lastdate != '' ) { $field = $event->object; if ($field->name == 'date_start' || $field->name == 'date_end') { // get the page being edited $page = $this->wire('modules')->ProcessPageEdit->getPage(); // ensure we don't save 'erroneous' dates; we revert to older saved (db) dates or blank $oldDate = $page->get($field->name); $field->value = $oldDate; // only show error on first date field if ($field->name == 'date_start') $field->error(""); if ($field->name == 'date_end') $field->error("") . $field->message("Das Datum zum $field->label muss in der Zukunft liegen, bitte die Angabe zum Veranstaltungsbeginn beachten!"); } } // Populate back return value, if you have modified it $event->return = $return; }); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now