Subject: | Error message for "missing" fields is the same as for "invalid" fields |
When using javascript => 0 option, make a form with a required field,
leave it blank, then submit it. The error message comes back as
"Invalid entry." While indeed it's invalid, it would be nice to be able
to report to the user that the field cannot be left blank. Since there
is only one "invalid" message type, using a custom message won't help
(since it will also show up for fields that are invalid due to input
errors as well). Attached is a patch that adds a new error message
type, form_missing_input. I only added it to Messages/default.pm as I'm
not sure how these are maintained.
Subject: | missing_patch.patch |
diff -u -r fb_orig\FormBuilder\Field.pm fb_msg\FormBuilder\Field.pm
--- fb_orig\FormBuilder\Field.pm Mon Mar 29 12:58:10 2010
+++ fb_msg\FormBuilder\Field.pm Mon Mar 29 14:30:43 2010
@@ -509,6 +509,11 @@
my $type = shift || $self->type;
my $et = 'form_invalid_' . ($type eq 'text' ? 'input' : $type);
$et = 'form_invalid_input' if $self->other; # other fields assume text
+
+ if($self->{'missing'}) {
+ $et = 'form_missing_input';
+ }
+
$mess = sprintf(($self->{_form}{messages}->$et
|| $self->{_form}{messages}->form_invalid_default), $self->label);
}
diff -u -r fb_orig\FormBuilder\Messages\default.pm fb_msg\FormBuilder\Messages\default.pm
--- fb_orig\FormBuilder\Messages\default.pm Mon Mar 29 12:58:10 2010
+++ fb_msg\FormBuilder\Messages\default.pm Mon Mar 29 14:30:43 2010
@@ -37,6 +37,7 @@
. 'Please correct the fields %shighlighted%s below.',
form_invalid_input => 'Invalid entry',
+ form_missing_input => 'This field is required',
form_invalid_hidden => 'Invalid entry',
form_invalid_select => 'Select an option from this list',
form_invalid_checkbox => 'Check one or more options',