Skip Menu |

This queue is for tickets about the Data-FormValidator CPAN distribution.

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 14594
Status: resolved
Priority: 0/
Queue: Data-FormValidator

People
Owner: MARKSTOS [...] cpan.org
Requestors: claco [...] chrislaco.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 4.02
Fixed in: (no value)



Subject: Custom Missing Messages Support
While working DFV into Handel, it became apparent that the missing field messages are geared towards being display right next to the field in question, and not em masse at the top of the page; where 5 "Missing" messages mean nothing to the user. After being sick of me complaining, Matt Trout tossed together the start of this patch. I tweaked it somewhat to deal with a default within the missing hash. In a nutshell, this patch: - Allows you to use the old style missing format: 'myprofile' => { missing => 'Custom Missing!' } - Allows you to create a hash containing a custom message per field: 'myprofile' => { missing => { default => 'Custom Missing', myfield => 'The field 'myfield' cannot be empty...' } } When using a hash, of no entry for a field is found, the default key/value is used. IF that is not found, 'Missing' is used.
--- Results.pm.orig Wed Aug 31 22:27:27 2005 +++ Results.pm Wed Sep 14 17:40:28 2005 @@ -584,7 +584,9 @@ if ($self->has_missing) { my $missing = $self->missing; for my $m (@$missing) { - $msgs{$m} = _error_msg_fmt($profile{format},$profile{missing}); + $msgs{$m} = _error_msg_fmt($profile{format}, + (ref $profile{missing} eq 'HASH' ? + ($profile{missing}->{$m} || $profile{missing}->{default} || 'Missing') : $profile{missing})); } }
Date: Wed, 14 Sep 2005 21:57:21 -0400
From: "Christopher H. Laco" <claco [...] chrislaco.com>
To: bug-Data-FormValidator [...] rt.cpan.org
Subject: Re: [cpan #14594] AutoReply: Custom Missing Messages Support
RT-Send-Cc:
Show quoted text
> In a nutshell, this patch: > > - Allows you to use the old style missing format: > > 'myprofile' => { > missing => 'Custom Missing!' > } > > - Allows you to create a hash containing a custom message per field: > > 'myprofile' => { > missing => { > default => 'Custom Missing', > myfield => 'The field 'myfield' cannot be empty...' > } > } > > When using a hash, of no entry for a field is found, the default key/value is used. IF that is not found, 'Missing' is used. > >
What I meant was: 'myprofile' => { msgs => { missing => 'Custom Missing!' } } 'myprofile' => { msgs => { missing => { default => 'Custom Missing', myfield => 'The field 'myfield' cannot be empty...' } } } -=Chris
Download smime.p7s
application/x-pkcs7-signature 4.1k

Message body not shown because it is not plain text.