Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Workflow CPAN distribution.

Report information
The Basics
Id: 20871
Status: resolved
Priority: 0/
Queue: Workflow

People
Owner: jonasbn [...] cpan.org
Requestors: michael.bell [...] cms.hu-berlin.de
Cc:
AdminCc:

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



Subject: Wrong accessor and implemented is_required="yes"
Date: Mon, 07 Aug 2006 11:33:59 +0200
To: bug-Workflow [...] rt.cpan.org
From: Michael Bell <michael.bell [...] cms.hu-berlin.de>
Download smime.p7s
application/x-pkcs7-signature 7.7k

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 1.2k
Hi, Workflow version: 0.21 Perl version: 5.8.8 uname -a: Linux XXX 2.6.17-1-686 #1 SMP ..date.. i686 GNU/Linux I fixed two bugs. 1. There are two functions - required_fields and optional_fields which should return the required and the optional fields. Both functions use the internal variable type which is wrong because Workflow::Action::InputField has an accessor for exactly this information. The accessor is the function requirement. 2. The documentation of Workflow::Validator::HasRequiredField announces that is_required="yes" in a field specification automatically creates the necessary validator. The code for this feature is simply missing. I added the missing code in front of the normal validator initialization. I attached the patch. If you have any questions or doubts please be free to contact me. If I do something wrong then I'm willing to fix this. Best regards Michael -- Show quoted text
_______________________________________________________________ Michael Bell Humboldt-Universitaet zu Berlin Tel.: +49 (0)30-2093 2482 ZE Computer- und Medienservice Fax: +49 (0)30-2093 2704 Unter den Linden 6 michael.bell@cms.hu-berlin.de D-10099 Berlin
_______________________________________________________________
Download Action.pm.diff
text/x-diff 2k
--- /usr/local/share/perl/5.8.4/Workflow/Action.pm.org 2006-07-18 09:44:17.000000000 +0200 +++ /usr/local/share/perl/5.8.4/Workflow/Action.pm 2006-07-18 12:11:04.000000000 +0200 @@ -10,6 +10,7 @@ use base qw( Workflow::Base ); use Log::Log4perl qw( get_logger ); use Workflow::Action::InputField; +use Workflow::Validator::HasRequiredField; use Workflow::Factory qw( FACTORY ); $Workflow::Action::VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); @@ -27,12 +28,12 @@ sub required_fields { my ( $self ) = @_; - return grep { $_->{type} eq 'required' } @{ $self->{_fields} }; + return grep { $_->requirement() eq 'required' } @{ $self->{_fields} }; } sub optional_fields { my ( $self ) = @_; - return grep { $_->{type} eq 'optional' } @{ $self->{_fields} }; + return grep { $_->requirement() eq 'optional' } @{ $self->{_fields} }; } sub fields { @@ -102,11 +103,31 @@ $self->name( $copy_params{name} ); $self->description( $copy_params{description} ); + ## init normal fields my @fields = $self->normalize_array( $copy_params{field} ); foreach my $field_info ( @fields ) { $self->add_fields( Workflow::Action::InputField->new( $field_info ) ); } + ## establish validator for fields with is_required="yes" + @fields = $self->required_fields(); + my $validator = Workflow::Validator::HasRequiredField->new ( + { + name => 'HasRequiredField for is_required fields', + class => 'Workflow::Validator::HasRequiredField' + }); + my @args = (); + foreach my $field ( @fields ) { + next if (not $field); ## empty @fields array + push @args, $field->name(); + } + push @{ $self->{_validators} }, + { + validator => $validator, + args => \@args + }; + + ## init normal validators my @validator_info = $self->normalize_array( $copy_params{validator} ); $self->add_validators( @validator_info );
Download (untitled) / with headers
text/plain 114b
Thanks Michael, I have applied your patch and it is on its way to CPAN (in release 0.22). Thanks again, jonasbn


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.