• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item3957: Mandatory fields will not accept 0

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Urgent Closed   minor 4.2.0

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


When a field is marked with attribute M on the form topic (the field is mandatory) it will not accept a value of 0: instead Topic Save Error is received with the error that the required field is not fillled in. This is the case for all field types (text, textarea, checkbox, radio, select). I expect the problem is testing the submitted field value for truth rather than non-zero length, which I suggest as the expected behavior.

-- TWiki:Main/DylanPartridge - 26 Apr 2007

Created test case TestCase3957

-- TWiki:Main.DylanPartridge - 26 Apr 2007

One possible fix is to apply this patch to lib/TWiki/Form.pm:

*** lib/TWiki/Form.pm.orig      Thu Apr 26 08:58:16 2007
--- lib/TWiki/Form.pm   Thu Apr 26 09:00:57 2007
*** 771,777 ****
!         if( $fieldDef->{attributes} =~ /M/ && !$value &&
                ( !$preDef || !$preDef->{value} ) ) {
              # Remember missing mandatory fields
              push( @missing, $fieldDef->{title} || "unnamed field" );
--- 771,777 ----
!         if( $fieldDef->{attributes} =~ /M/ && !length($value) &&
                ( !$preDef || !$preDef->{value} ) ) {
              # Remember missing mandatory fields
              push( @missing, $fieldDef->{title} || "unnamed field" );

-- DylanPartridge - 26 Apr 2007

Thanks Dylan, your analysis, testcase and code were extremely helpful. I fixed it slightly differently, but in retrospect your way is cleaner (I will remember it for the future).

Fixed on MAIN and Patch04x01


Summary Mandatory fields will not accept 0
ReportedBy TWiki:Main.DylanPartridge
Codebase 4.1.2
SVN Range TWiki-4.1.2, Sun, 15 Apr 2007, build 13419
AppliesTo Engine

Priority Urgent
CurrentState Closed

Checkins TWikirev:13534 TWikirev:13535
TargetRelease minor
ReleasedIn 4.2.0
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r9 - 2008-01-22 - KennethLavrsen
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback