1Workflow::Action::InputUFsieerldC(o3n)tributed Perl DocuWmoernktfaltoiwo:n:Action::InputField(3)
2
3
4

NAME

6       Workflow::Action::InputField - Metadata about information required by
7       an Action
8

VERSION

10       This documentation describes version 1.09 of this package
11

SYNOPSIS

13        # Declare the fields needed by your action in the configuration...
14
15        <action name="CreateUser">
16           <field name="username"
17                  is_required="yes"
18                  source_class="App::Field::ValidUsers" />
19           <field name="email"
20                  is_required="yes" />
21           <field name="office"
22                  source_list="Pittsburgh,Hong Kong,Moscow,Portland" />
23        ...
24

DESCRIPTION

26       A workflow Action can declare one or more input fields required to do
27       its job. Think of it as a way for the external world (your application)
28       to discover what information an action needs from it. The application
29       can request these fields from the workflow by action name and present
30       them to the user in whatever form appropriate for the application. The
31       sample command-line application shipped with this distribution just
32       cycles through them one at a time and presents a query to the user for
33       data entry.
34
35       For instance, in the above declaration there are three fields,
36       'username', 'email' and 'office'. So your application might do:
37
38        my @action_fields = $wf->get_action_fields( 'CreateUser' );
39        foreach my $field ( @action_fields ) {
40            print "Field ", $field->name, "\n",
41                  $field->description, "\n",
42                  "Required? ", $field->is_required, "\n";
43            my @enum = $field->get_possible_values;
44            if ( scalar @enum ) {
45                print "Possible values: \n";
46                foreach my $val ( @enum ) {
47                    print "  $val->{label} ($val->{value})\n";
48                }
49            }
50            print "Input? ";
51            my $response = <STDIN>;
52            chomp $response;
53            $wf->context->param( $field->name => $response );
54        }
55        $wf->execute_action( 'CreateUser' );
56

METHODS

58   Public Methods
59       new( \%params )
60
61       Typical constructor; will throw exception if 'name' is not defined or
62       if the property 'source_class' is defined but the class it specifies is
63       not available.
64
65       is_required()
66
67       Returns 'yes' if field is required, 'no' if optional.
68
69       is_optional()
70
71       Returns 'yes' if field is optional, 'no' if required.
72
73       get_possible_values()
74
75       Returns list of possible values for this field. Each possible value is
76       represented by a hashref with the keys 'label' and 'value' which makes
77       it easy to create dropdown lists in templates and the like.
78
79       add_possible_values( @values )
80
81       Adds possible values to be used for this field. Each item in @values
82       may be a simple scalar or a hashref with the keys 'label' and 'value'.
83
84       init
85
86       Init is a dummy and just returns no special actions are taken
87
88   Properties
89       name (required)
90
91       Name of the field. This is what the action expects as the key in the
92       workflow context.
93
94       label (optional)
95
96       Label of the field. If not set the value for "name" is used.
97
98       description (optional)
99
100       What does the field mean? This is not required for operation but it is
101       strongly encouraged so your clients can create front ends to feed you
102       the information without much fuss.
103
104       type (optional)
105
106       TODO: Datatype of field (still under construction...). By default it is
107       set to 'basic'.
108
109       requirement ('required'|'optional')
110
111       If field is required, 'required', otherwise 'optional'.
112
113       source_class (optional)
114
115       If set the field will call 'get_possible_values()' on the class when
116       the field is instantiated. This should return a list of either simple
117       scalars or a list of hashrefs with 'label' and 'value' keys.
118
119       source_list (optional)
120
121       If set the field will use the specified comma-separated values as the
122       possible values for the field. The resulting list returned from
123       "get_possible_values()" will have the same value for both the 'label'
124       and 'value' keys.
125

SEE ALSO

127       Workflow::Action
128
130       Copyright (c) 2003-2007 Chris Winters. All rights reserved.
131
132       This library is free software; you can redistribute it and/or modify it
133       under the same terms as Perl itself.
134

AUTHORS

136       Jonas B. Nielsen (jonasbn) <jonasbn@cpan.org> is the current
137       maintainer.
138
139       Chris Winters <chris@cwinters.com>, original author.
140
141
142
143perl v5.12.0                      2010-05-07   Workflow::Action::InputField(3)
Impressum