public function define_after_data(&$mform) {
        global $DB;

        // If we are adding a new profile field then the dates have already been set
        // by setDefault to the correct dates in the used calendar system. We only want
        // to execute the rest of the code when we have the years in the DB saved in
        // Gregorian that need converting to the date for this user.
        $id = required_param('id', PARAM_INT);
        if ($id === 0) {
            return;
        }

        // Get the field data from the DB.
        $field = $DB->get_record('user_info_field', array('id' => $id), 'param1, param2', MUST_EXIST);

        // Get the current calendar in use - see MDL-18375.
        $calendartype = \core_calendar\type_factory::get_calendar_instance();

        // An array to store form values.
        $values = array();

        // The start and end year will be set as a Gregorian year in the DB. We want
        // convert these to the equivalent year in the current calendar type being used.
        $startdate = $calendartype->convert_from_gregorian($field->param1, 1, 1);
        $values['startday'] = $startdate['day'];
        $values['startmonth'] = $startdate['month'];
        $values['startyear'] = $startdate['year'];
        $values['param1'] = $startdate['year'];

        $stopdate = $calendartype->convert_from_gregorian($field->param2, 1, 1);
        $values['endday'] = $stopdate['day'];
        $values['endmonth'] = $stopdate['month'];
        $values['endyear'] = $stopdate['year'];
        $values['param2'] = $stopdate['year'];

        // Set the values.
        foreach ($values as $key => $value) {
            $param = $mform->getElement($key);
            $param->setValue($value);
        }
    }