Rechercher une page de manuel
Workflow::Action::InputField.3pm
Langue: en
Version: 2010-05-07 (fedora - 01/12/10)
Section: 3 (Bibliothèques de fonctions)
NAME
Workflow::Action::InputField - Metadata about information required by an ActionVERSION
This documentation describes version 1.09 of this packageSYNOPSIS
# Declare the fields needed by your action in the configuration... <action name="CreateUser"> <field name="username" is_required="yes" source_class="App::Field::ValidUsers" /> <field name="email" is_required="yes" /> <field name="office" source_list="Pittsburgh,Hong Kong,Moscow,Portland" /> ...
DESCRIPTION
A workflow Action can declare one or more input fields required to do its job. Think of it as a way for the external world (your application) to discover what information an action needs from it. The application can request these fields from the workflow by action name and present them to the user in whatever form appropriate for the application. The sample command-line application shipped with this distribution just cycles through them one at a time and presents a query to the user for data entry.For instance, in the above declaration there are three fields, 'username', 'email' and 'office'. So your application might do:
my @action_fields = $wf->get_action_fields( 'CreateUser' ); foreach my $field ( @action_fields ) { print "Field ", $field->name, "\n", $field->description, "\n", "Required? ", $field->is_required, "\n"; my @enum = $field->get_possible_values; if ( scalar @enum ) { print "Possible values: \n"; foreach my $val ( @enum ) { print " $val->{label} ($val->{value})\n"; } } print "Input? "; my $response = <STDIN>; chomp $response; $wf->context->param( $field->name => $response ); } $wf->execute_action( 'CreateUser' );
METHODS
Public Methods
new( \%params )Typical constructor; will throw exception if 'name' is not defined or if the property 'source_class' is defined but the class it specifies is not available.
is_required()
Returns 'yes' if field is required, 'no' if optional.
is_optional()
Returns 'yes' if field is optional, 'no' if required.
get_possible_values()
Returns list of possible values for this field. Each possible value is represented by a hashref with the keys 'label' and 'value' which makes it easy to create dropdown lists in templates and the like.
add_possible_values( @values )
Adds possible values to be used for this field. Each item in @values may be a simple scalar or a hashref with the keys 'label' and 'value'.
init
Init is a dummy and just returns no special actions are taken
Properties
name (required)Name of the field. This is what the action expects as the key in the workflow context.
label (optional)
Label of the field. If not set the value for "name" is used.
description (optional)
What does the field mean? This is not required for operation but it is strongly encouraged so your clients can create front ends to feed you the information without much fuss.
type (optional)
TODO: Datatype of field (still under construction...). By default it is set to 'basic'.
requirement ('required'|'optional')
If field is required, 'required', otherwise 'optional'.
source_class (optional)
If set the field will call 'get_possible_values()' on the class when the field is instantiated. This should return a list of either simple scalars or a list of hashrefs with 'label' and 'value' keys.
source_list (optional)
If set the field will use the specified comma-separated values as the possible values for the field. The resulting list returned from "get_possible_values()" will have the same value for both the 'label' and 'value' keys.
SEE ALSO
Workflow::ActionCOPYRIGHT
Copyright (c) 2003-2007 Chris Winters. All rights reserved.This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHORS
Jonas B. Nielsen (jonasbn) <jonasbn@cpan.org> is the current maintainer.Chris Winters <chris@cwinters.com>, original author.
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre