diff --git a/lib/WebGUI/Form/Control.pm b/lib/WebGUI/Form/Control.pm index 82a2b4014..809fbbf3a 100644 --- a/lib/WebGUI/Form/Control.pm +++ b/lib/WebGUI/Form/Control.pm @@ -80,6 +80,11 @@ The starting value for the field. If no starting value is specified, this will be used instead. +=head4 _defaulted + +This flag indicates that the defaultValue was used. It is used by Form types that support +an initial blank field, instead of using a default, like WebGUI::Form::Date.pm + =head4 extras Add extra attributes to the form tag like @@ -146,6 +151,9 @@ sub definition { defaultValue=>{ defaultValue=>undef }, + _defaulted=>{ + defaultValue=>0 + }, label=>{ defaultValue=>undef }, @@ -353,8 +361,11 @@ sub new { } } # if the value field is undefined, lets use the defaultValue field instead + # the _defaulted field is used to tell form fields that support noDate/noValue + # options whether the field can be safely cleared or not. unless (exists $params{value}) { $params{value} = $params{defaultValue}; + $params{_defaulted} = 1; } # doesn't have an id specified, so let's give it one unless ($params{id}) { diff --git a/lib/WebGUI/Form/Date.pm b/lib/WebGUI/Form/Date.pm index 33cb998cf..5e99b6171 100644 --- a/lib/WebGUI/Form/Date.pm +++ b/lib/WebGUI/Form/Date.pm @@ -61,7 +61,7 @@ Defaults to 10. The displayed size of the box for the date to be typed in. =head4 noDate -By default a date is placed in the value field. Set this to "1" to leave it empty. +A default date is placed in the value field. Set this to "1" to leave it empty. =head4 defaultValue @@ -125,7 +125,7 @@ Renders a date picker control. sub toHtml { my $self = shift; - if ($self->{noDate} ) { + if ($self->{_defaulted} && $self->{noDate} ) { $self->{value} = ''; } else {