Hi...
I'm trying to make the issues "description" field non mandatory, and to default to the same content as "summary"...
I've searched in here and tried this:
in bug_api.php:
if( $p_update_extended ) {
# Description field cannot be empty
// if( is_blank( $this->description ) ) {
// error_parameters( lang_get( 'description' ) );
// trigger_error( ERROR_EMPTY_FIELD, ERROR );
// }
}
and in bug_report.php:
$t_issue = array(
'project' => array( 'id' => $t_project_id ),
'reporter' => array( 'id' => auth_get_current_user_id() ),
'summary' => gpc_get_string( 'summary' ),
'description' => gpc_get_string( 'description',''),
);
if ( is_blank( $t_issue->description ) ) {
$t_issue->description = $t_issue->summary;
}
however, it doesn't work....
Any suggestions please?
Thanks!
Make a field non required
Moderators: Developer, Contributor
Re: Make a field non required
Why remove the check?
In your bug_report.php, you already fill the description field if it is empty.
I would use the following line of code:
if ( trim($t_issue->description) == "" ) ) {
In your bug_report.php, you already fill the description field if it is empty.
I would use the following line of code:
if ( trim($t_issue->description) == "" ) ) {
Re: Make a field non required
The change to bug_report.php made no difference. Mantis still insists on the field being entered, so the summary data never gets put into description.
So, the change to bug_api.php was to try and stop the requirement to enter data into description - the check has to be removed else the above change doesn't get a chance to work.
So - the problem is that both the changes I tried make *no difference at all* to how it works!
I still cannot save an issue without manually entering description data.
I should have said, this is Mantis 2.24.1
I've seen other people in here try and do this, but without success...
Any help appreciated!
So, the change to bug_api.php was to try and stop the requirement to enter data into description - the check has to be removed else the above change doesn't get a chance to work.
So - the problem is that both the changes I tried make *no difference at all* to how it works!
I still cannot save an issue without manually entering description data.
I should have said, this is Mantis 2.24.1
I've seen other people in here try and do this, but without success...
Any help appreciated!
Re: Make a field non required
Although rather not change core code, this should work:
Change this code (bug_report.php):
into:
I have not tried it but this should do the trick.
Change this code (bug_report.php):
Code: Select all
$t_issue = array(
'project' => array( 'id' => $t_project_id ),
'reporter' => array( 'id' => auth_get_current_user_id() ),
'summary' => gpc_get_string( 'summary' ),
'description' => gpc_get_string( 'description' ),
);
Code: Select all
$t_sum= gpc_get_string( 'summary' );
$t_desc= trim(gpc_get_string( 'description' ));
if ($t_desc == ""){
$t_desc= $t_sum;
}
$t_issue = array(
'project' => array( 'id' => $t_project_id ),
'reporter' => array( 'id' => auth_get_current_user_id() ),
'summary' => $t_sum),
'description' => $t_desc,
);
Re: Make a field non required
No time to have a deeper look, but I assume you are on the wrong track.
You have to remove "required" from the following line, to prevent browser from checking the empty textarea when pushing the "Submit Issue" button.
You have to remove "required" from the following line, to prevent browser from checking the empty textarea when pushing the "Submit Issue" button.
Code: Select all
<textarea class="form-control" <?php echo helper_get_tab_index() ?> id="description" name="description" cols="80" rows="10" required>
Re: Make a field non required
You are right, missed the obvious as usual
Re: Make a field non required
Thanks atrol, but this is a bit odd.
I change line 574 in bug_report_page.php to:
It then alters the field to 5 rows - so it's affecting the right area - but it's still a required field!
The "*" is still there - it now allows the browser to proceed but then I get:
I change line 574 in bug_report_page.php to:
Code: Select all
<textarea class="form-control" <?php echo helper_get_tab_index() ?> id="description" name="description" cols="80" rows="5">
The "*" is still there - it now allows the browser to proceed but then I get:
So there's something else still affecting that... I thought my tweak to bug_api.php would have stopped the app error 11?APPLICATION ERROR #11
A necessary field "description" was empty. Please recheck your inputs.
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.
Re: Make a field non required
You also can set a default description in config_inc.php using this variable:
/**
* Default value for bug description field used on bug report page.
*
* @global string $g_default_bug_description
*/
$g_default_bug_description = 'See Summary';
All solved without any changes to the code
/**
* Default value for bug description field used on bug report page.
*
* @global string $g_default_bug_description
*/
$g_default_bug_description = 'See Summary';
All solved without any changes to the code
Re: Make a field non required
cas - that's nifty - thanks!