This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

durika.d23488
durika.d23488

Hi, i have CalendarModel Event with 'from' (date) and 'to' (date) fields how can i setup backend form validation to ensure that 'to date' is always after 'from date'?

thx

balex7033469
balex7033469

If its still relevant to you or in case someone stumble on same problem. You can do like that. Add beforeValidate method in your Controller:


public function beforeValidate() {
        if($this->date_start > $this->date_end) {
            throw new \ValidationException(['date' => trans('rd.easy::lang.date_start_end_error')]);
        }
    }

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.