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
CC