View Issue Details

IDProjectCategoryView StatusLast Update
0010670mantisbtcustom fieldspublic2010-02-22 14:35
ReporterDagan Assigned Tovboctor  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformWINDOWS OS2003 SERVER 
Product Version1.1.8 
Fixed in Version1.2.0 
Summary0010670: Custom fields required do not work
Description

We create different custom fields with the Required option (for example for Registering) and when we register an issue and leave the field empty, mantis do not show and advise and lets save the issue.

Steps To Reproduce
  • Create a custom field with the Required On Report option checked.
  • Add the custom field to a project.
  • Create an issue for this project and leave the custom field empty (you can see the * char before the field, so should be required.
  • Save the issue and see that you do no get any error message.
TagsNo tags attached.

Relationships

has duplicate 0011057 closedvboctor Failed to validate required custom fields 
has duplicate 0010805 closedvboctor Required on Close is ignored 
has duplicate 0005301 closedvboctor Custom field of type 'list' not required when expected 
has duplicate 0008082 closedvboctor Required custom fields seems not working 
has duplicate 0011568 closeddhx Custom fields marked as mandatory are not mandatory ... 

Activities

capadam

capadam

2009-07-03 08:27

reporter   ~0022362

Last edited: 2009-07-03 08:28

I have the same problem with Mantis on my project.

Dagan

Dagan

2009-07-03 08:45

reporter   ~0022363

Last edited: 2009-07-03 08:51

I think I have find out why is happening. There are two problems:

  • The first one is that (unless with SQL Server) when we create an issue, all the Custom fields appear filled with a white space (' '). So when you save the issue are not empty.
  • The second one is that in the bug_report.php file, when the foreach bucle of custom fields is made, there is no check for the field value so the error is never shown. I have added the next lines in this file:
    if ($t_def['require_report'] && (gpc_get_custom_field( "customfield$t_id", $t_def['type'], NULL )==''||gpc_get_custom_field( "customfield$t_id", $t_def['type'], NULL )==NULL)){
    error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
    trigger_error( ERROR_EMPTY_FIELD, ERROR );
    }

In the 96 line, after this IF:

if ( $t_def['require_report'] && !gpc_isset_custom_field( $t_id, $t_def['type'] ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}
And it seems its working.

I don't know if this is php correct code (is the first time in my life I work with this language), but works :D.

capadam

capadam

2009-07-03 09:45

reporter   ~0022364

Thanks for suggestion.
I have one question for your solution:
Is this
"if ($t_def['require_report'] && (gpc_get_custom_field( "customfield$t_id", $t_def['type'], NULL )==''||gpc_get_custom_field( "customfield$t_id", $t_def['type'], NULL )==NULL)){
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}
I add to end off line or between some lines in code ?
Regards,

Dagan

Dagan

2009-07-06 03:10

reporter   ~0022409

You have to add it in:

  • In the bug_report.php after the 96 line, just down the first If I wrote in my message.
  • In the bug_update.php after the 130 line, just down the same If.
capadam

capadam

2009-07-06 03:58

reporter   ~0022411

Thank's Dagan. It's working but only if I register new bug (problem). What I must do that this solution work during Resolve problem and Close. I have require fields too in this status.
Thanks for replay,
Adam

jpp156

jpp156

2009-10-26 15:45

reporter   ~0023357

I am seeing the same issue here with 1.1.8. It doesn't seem possible to use "required field" with Enumerations.
I picked Type "List" with "Min. Length" as 1 where my possilbe values are "Manufacturing|Test Execution|Other". This seemed to work fine.

sabkaraja

sabkaraja

2009-10-28 02:51

reporter   ~0023436

I have two custom fields in my project, one to be entered by reporter (reports/updates issues), and the other entered by the developer (resolves/closes issues)

I have set required for Report & update for 1st, and Required for Resolved & Closed for the other.

However, when the user is reporting the issue, its validating the required for resolved fields as well. I am using Mantis: 1.1.8

As reported earlier, I have to force validation by setting min. field length to 1

atrol

atrol

2009-11-17 05:59

developer   ~0023737

still the same in 1.2.0rc2

aCCuReRaS

aCCuReRaS

2009-12-21 06:43

reporter   ~0023938

Last edited: 2009-12-21 06:44

I have the same problem in 1.2.0-RC1. We are running on linux, apache in combi with MySQL 5.
Can this one be fixed in the final 1.2.0?

Related Changesets

MantisBT: master-1.2.x dfbe8b56

2010-01-20 23:06

vboctor


Details Diff
Fixes 0010670: Custom fields required do not work. Affected Issues
0010670
mod - core/cfdefs/cfdef_standard.php Diff File
mod - core/gpc_api.php Diff File

MantisBT: master e45c8298

2010-01-20 23:06

vboctor


Details Diff
Fixes 0010670: Custom fields required do not work. Affected Issues
0010670
mod - core/cfdefs/cfdef_standard.php Diff File
mod - core/gpc_api.php Diff File