HTML-Template-Associate-FormField
view release on metacpan or search on metacpan
lib/HTML/Template/Associate/FormField.pm view on Meta::CPAN
sub __filefield { filefield(&_proc_value) }
sub __file { &__filefield }
sub __password_field { password_field(&_proc_value) }
sub __password { &__password_field }
sub __textarea { textarea(&_proc_value) }
sub __button { button($_[1]) }
sub __reset { reset($_[1]) }
sub __defaults { defaults($_[1]) }
sub __checkbox { checkbox(&_proc_defaults) }
sub __checkbox_group { checkbox_group(&_proc_defaults) }
sub __popup_menu { popup_menu(&_proc_defaults) }
sub __scrolling_list { scrolling_list(&_proc_defaults) }
sub __select { &__popup_menu }
sub __radio_group { radio_group(&_proc_default) }
sub __radio { &__radio_group }
sub __image_button { image_button($_[1]) }
sub __image { image_button($_[1]) }
sub __submit { submit($_[1]) }
package HTML::Template::Associate::FormField::Param;
use strict;
lib/HTML/Template/Associate/FormField.pm view on Meta::CPAN
The contents of each key certainly be defined the key ,type, which shows type
of Form Field.
=item *
The value of designate to type is same as method for making Form Field of
CGI.pm. B<Please refer to document of CGI.pm for details>.
B<startform> , B<start_multipart_form> , B<endform> , B<textfield> ,
B<filefield> , B<password_field> , B<textarea> , B<checkbox> , B<radio_group>
, B<popup_menu> , B<optgroup> , B<scrolling_list> , B<image_button> ,
B<defaults> , B<button> , B<reset>
=item *
And others, be possible to designate for extension Field type
at B<HTML::Template::Associate::FormField> are as follows:
B<form> ... other name of startform. I<(%)>
B<start_upload_form> ... other name of start_multipart_form. I<(%)>
lib/HTML/Template/Associate/FormField.pm view on Meta::CPAN
B<hidden> ... other name of hidden_field
B<text> ... other name of textfield.
B<file> ... other name of filefield.
B<password> ... other name of password_field.
B<radio> ... other name of radio_group.
B<select> ... other name of popup_menu.
B<image> ... other name of image_button.
I<(%) In case of no indication Field was set up ,
connect the no indication Field and return the value.>
=item *
In case of you'd like to acquire the name from CGI query - it is different name
of the key which definition of Form Field, designate for the name of CGI query
t/03_output.t view on Meta::CPAN
my %formfields= (
start_multipart_form=> { type=> 'start_multipart_form' },
startform => { type=> 'startform' },
textfield => { type=> 'textfield' },
filefield => { type=> 'filefield' },
textarea => { type=> 'textarea' },
password => { type=> 'password' },
checkbox => { type=> 'checkbox' },
checkbox_group=> { type=> 'checkbox_group', values=> ['foo', 'baz'] },
radio_group => { type=> 'radio_group', values=> ['foo', 'baz'] },
popup_menu => { type=> 'popup_menu', values=> ['foo', 'baz'] },
scrolling_list=> { type=> 'scrolling_list', values=> ['foo', 'baz'] },
image_button => { type=> 'image_button', src=> './dummy.gif' },
button => { type=> 'button', onclick=> 'history.back();' },
reset => { type=> 'reset' },
defaults => { type=> 'defaults' },
submit => { type=> 'submit' },
);
my $template= <<END_OF_TEMPLATE;
[startform:<TMPL_VAR NAME="__startform__">]
[start_multipart_form:<TMPL_VAR NAME="__start_multipart_form__">]
[textfield:<TMPL_VAR NAME="__textfield__">]
[filefield:<TMPL_VAR NAME="__filefield__">]
[textarea:<TMPL_VAR NAME="__textarea__">]
[password:<TMPL_VAR NAME="__password__">]
[checkbox:<TMPL_VAR NAME="__checkbox__">]
[checkbox_group:<TMPL_VAR NAME="__checkbox_group__">]
[radio_group:<TMPL_VAR NAME="__radio_group__">]
[popup_menu:<TMPL_VAR NAME="__popup_menu__">]
[scrolling_list:<TMPL_VAR NAME="__scrolling_list__">]
[image_button:<TMPL_VAR NAME="__image_button__">]
[button:<TMPL_VAR NAME="__button__">]
[reset:<TMPL_VAR NAME="__reset__">]
[defaults:<TMPL_VAR NAME="__defaults__">]
[submit:<TMPL_VAR NAME="__submit__">]
END_OF_TEMPLATE
my %hash= (
textfield=> 'foo',
filefield=> 'foo',
textarea => 'foo',
password => 'foo',
checkbox => 'foo',
checkbox_group=> 'foo',
radio_group=> 'foo',
popup_menu => 'foo',
scrolling_list=> 'foo',
);
my $form= HTML::Template::Associate::FormField->new(\%hash, \%formfields);
my $tp = HTML::Template->new( scalarref=> \$template, associate=> [$form] );
#> 1
ok($tp->isa('HTML::Template'));
#> 2
t/03_output.t view on Meta::CPAN
is(($out=~/\[checkbox_group\:(.+?)\]/s && do {
my @chk= ($1=~/(checkbox_group)/g);
@chk}), 2);
#> 11
is(($out=~/\[radio_group\:(.+?)\]/s && do {
my @chk= ($1=~/(radio_group)/g);
@chk}), 2);
#> 12
is(($out=~/\[popup_menu\:(.+?)\]/s && do {
my @chk= ($1=~/(<option)/ig);
@chk}), 2);
#> 13
is(($out=~/\[scrolling_list\:(.+?)\]/s && do {
my @chk= ($1=~/(<option)/ig);
@chk}), 2);
#> 14
ok($out=~/\[image_button\:(.+?)\]/s && $1=~/image_button/);
( run in 2.391 seconds using v1.01-cache-2.11-cpan-364913b4093 )