NAME

CGI::FormBuilderX::More - Additional input gathering/interrogating functionality for CGI::FormBuilder

VERSION

Version 0.011

SYNOPSIS

use CGI::FormBuilderX::More;

my $form = CGI::FormBuilderX::More( ... );

if ($form->pressed("edit")) {
    my $input = $form->input_slice(qw/title description/);
    # $input is { title => ..., description => ... } *ONLY*
    ...
}
elsif ($form->pressed("view") && ! $form->missing("section")) {
    # the paramter "section" is defined and is not ''
    ...
}

...

print $form->render;

DESCRIPTION

CGI::FormBuilderX::More extends CGI::FormBuilder by adding some convenience methods. Specifically, it adds methods for generating param lists, generating param hash slices, determining whether a param is "missing", and finding out which submit button was pressed.

EXPORT

missing( <value> )

Returns 1 if <value> is not defined or the empty string ('') Returns 0 otherwise

Note, the number 0 is NOT a "missing" value

METHODS

CGI::FormBuilderX::More->new( ... )

Returns a new CGI::FormBuilderX::More object

Configure exactly as you would a normal CGI::FormBuilder object

pressed( <name> )

Returns the value of ->param(<name>) if <name> exists and has a value

If not, then returns the value of ->param("<name>.x") if "<name>.x" exists and has a value

Otherwise, returns undef

Essentially, you can use this method to find out which button the user pressed. This method does not require any javascript on the client side to work

It checks "<name>.x" because for image buttons, some browsers only submit the .x and .y values of where the user pressed.

missing( <name> )

Returns 1 if value of the param <name> is not defined or the empty string ('') Returns 0 otherwise

Note, the number 0 is NOT a "missing" value

input ( <name>, <name>, ..., <name> )

Returns a list of values based on the param names given

By default, this method will "collapse" multi-value params into the first value of the param. If you'd prefer an array reference of multi-value params instead, pass the option { all => 1 } as the first argument (a hash reference).

input_slice( <name>, <name>, ..., <name> )

Returns a hash of key/value pairs based on the param names given

By default, this method will "collapse" multi-value params into the first value of the param. If you'd prefer an array reference of multi-value params instead, pass the option { all => 1 } as the first argument (a hash reference).

input_param( <name> )

In list context, returns the all the param values associated with <name> In scalar context, returns only the first param value associated with <name>

AUTHOR

Robert Krimen, <rkrimen at cpan.org>

BUGS

Please report any bugs or feature requests to bug-cgi-formbuilderx-more at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-FormBuilderX-More. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc CGI::FormBuilderX::More

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2007 Robert Krimen, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.