Ho to make a field mandatory?

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Lenge
Posts: 6
Joined: 09 Aug 2008, 15:12

Ho to make a field mandatory?

Post by Lenge »

Hello world,

how can I configure Mantis 1.1.2 to make a built-in field (e. g. "Product Build") mandatory when a reporter enters a new issue?
All I found in the docs and the internet refers to custom fields only...

Cheers,
Jens
sckerr
Posts: 5
Joined: 15 Aug 2008, 05:35

Re: Ho to make a field mandatory?

Post by sckerr »

I think you want to take a look at this thread: http://www.mantisbt.org/forums/viewtopi ... ory#p13943

I had the same question and found this solution with a little searching around this forum.

Good luck!
sckerr
Posts: 5
Joined: 15 Aug 2008, 05:35

Re: Ho to make a field mandatory?

Post by sckerr »

NOTE: I did find that the solution did not work for me exactly as-is for version 1.1.2. The line:

define( 'ERROR_BUG_UPDATE_VALIDATE_FAILURE', 10001 );

That the solution states should be in custom_functions_inc.php actually needs to be in the file custom_constant_inc.php. Otherwise this solution works perfectly!

The next piece I'm trying to get is I want an asterisk to appear by the required field on the specified page. Once I have it, I'll post the solution here.
sckerr
Posts: 5
Joined: 15 Aug 2008, 05:35

Re: Ho to make a field mandatory?

Post by sckerr »

Disclaimer: I don't know how these changes will be retained at the next upgrade you take, but they work perfectly. It would be nice if there was a config file that we could define a field(s) that was mandatory and in which state(s).

To get the asterisk (*) by the field and the nice little "* required" by the submit button, I updated bug_change_status_page.php to change the following -

changed this:

Code: Select all

           <?php echo lang_get( 'fixed_in_version' ) ?>
to this:

Code: Select all

           <?php if ( $f_new_status == $t_resolved ) { ?>
                <span class="required">*</span><?php echo lang_get( 'fixed_in_version' ) ?>
           <?php } else { ?>
                <?php echo lang_get( 'fixed_in_version' ) ?>
           <?php } ?>
To get the "* required" by the submit button I changed this:

Code: Select all

        <td class="center" colspan="2">
                <input type="submit" class="button" value="<?php echo lang_get( $t_status_label . '_bug_button' ) ?>" />
        </td>
to this:

Code: Select all

        <td class="left">
        <span class="required"> * <?php echo lang_get( 'required' ) ?></span>
        </td>
        <td class="center">
                <input type="submit" class="button" value="<?php echo lang_get( $t_status_label . '_bug_button' ) ?>" />
        </td>
As you can see, my specific goal was to identify the "Fixed in Version" field as a required field when transitioning an issue to the resolved state. These changes work great. I will probably end up modifying my implementation so that it is also mandatory when transitioning the change request to the "closed" state as well.
sckerr
Posts: 5
Joined: 15 Aug 2008, 05:35

Re: Ho to make a field mandatory?

Post by sckerr »

Closing the loop on this, to ensure the field is populated and marked as required from the desired state on, you just change the checks for the code we added/updated in both custom_functions_inc.php and bug_change_status_page.php to be ">=" instead of "==". I should have seen that earlier.
Post Reply