Search code examples
phpdatemantis

Mantis custom field "date" giving odd default values


For collecting Date of Manufacture when customers open new issues, I added a custom field to my Mantis install (cur ver) with the type "date". I did not specify default values or possible values.

Mantis creates the following HTML on its own:

<tr class="row-2">
    <td class="category"><span class="required">*</span>Date of Manufacture</td>
    <td>
        <select tabindex="6" name="custom_field_3_year">
            <option value="0"></option>
            <option value="2011">2011</option>
            ...snip...
            <option value="2019">2019</option>
        </select>
        <select tabindex="7" name="custom_field_3_month">
            <option value="0"></option>
            <option value="1">January</option>
            ...snip...
            <option value="12">December</option>
        </select>
        <select tabindex="8" name="custom_field_3_day">
            <option value="0"></option>
            <option value="1">1</option>
            ...snip...
            <option value="31">31</option>
        </select>
    </td>
</tr>

The month and day bits are ok, and we don't particularly care if the user inputs an impossible day like February 30th.

However, the years are screwed. For whatever reason it starts at 2011 and runs through 2019. Because it's a select box you cannot manually input dates.

What is determining the year range? How can I set it to something appropriate?


Solution

  • I found the answer to my problem on the MantisBT help forum here.

    Add these lines to file config_inc.php and adjust to your needs

       /**
        * Number of years in the past that custom date fields will display in
        * drop down boxes.
        * @global int $g_backward_year_count
        */
       $g_backward_year_count             = 4;
    
       /**
        * Number of years in the future that custom date fields will display in
        * drop down boxes.
        * @global int $g_forward_year_count
        */
       $g_forward_year_count             = 4;