• If you look in the validation function you will find that the year is hardcoded to 1980 minimum.

    I’ve added in support for the total_years option that it already has but wasn’t using here.

    I also added in two nice extra features. It checks if the date is past today, and also correctly validates the days in the month, depending on the selected month and year:

    
    public function validate_value($valid, $value, $field, $input)
    {
        if (empty($value)
            || empty($value["date_month"])
            || empty($value["date_day"])
            || empty($value["date_year"])
        ) {
            return false;
        }
    
        $year = intval($value["date_year"]);
        $month = intval($value["date_month"]);
        $day = intval($value["date_day"]);
    
        if ($month < 1 || $month > 12) {
            return "Invalid Month";
        }
    
        $days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
    
        if ($day < 1 || $day > $days_in_month) {
            return "Invalid Day";
        }
    
        $current_year = date("Y");
        $minimum_year = $current_year - intval($field['total_years']);
    
        if ($year < $minimum_year || $year > $current_year) {
            return "Invalid Year";
        }
    
        // check not in future
        $selected_date = new DateTime("$year-$month-$day");
        if($selected_date > new DateTime()) {
            return "Date is in the future.";
        }
    
        // return
        return $valid;
    }
    

    Note: if the author reads this and wants to, please do incorporate this fix into the plugin.

  • The topic ‘bugfix – validation clamped to 1980, plus other improvements’ is closed to new replies.