Package DE_EPAGES::WebInterface::API::Form
This module is used to parse HTML forms. It recognizes normal web forms (application/x-www-form-urlencoded) and handles file uploads (multipart/form-data). Form data can be submitted by either GET or POST request.
Example |
my $Form = DE_EPAGES::WebInterface::API::Form->new( $HttpRequest ); my $UserName = $Form->values->{'user_name'}; |
Functions
encoding
Returns name encoding of current form. This functions has follings priorities
- 1. input field '_charset_' (some browser)
- 2. input field '_charset' (manual input field)
- 3. default charset 'utf-8'
Syntax |
$encoding = $self->encoding; |
existsValue
Return 1 if input name exists at post or get parameter.
Syntax |
$Exists = $Form->existsValue($InputName); |
Input |
|
Return |
|
file
Returns the content of an uploaded file. Note: uploading files requires the attributes method="post" enctype="multipart/form-data" on the form element.
Syntax |
$File = $Form->file($InputName); |
Example |
my @ProductImages = $Form->file('ProductImage'); my $ProductImage = $Form->file('ProductImage'); |
Return |
|
files
Returns the content of all uploaded files as hash reference. Each hash value is an array, because there may be multiple input fields with the same name. Use the values method to get the corresponding file names.
Syntax |
$haFiles = $Form->files; |
Example |
my $Content = $Form->files->{'ProductImage'}->[0]; my $FileName = $Form->values->{'ProductImage'}->[0]; |
Return |
|
formValue
Returns all POST values for a given field name. If the form element is a file-upload element, then the value contains the file name and the content can be determined by the file method.
Syntax |
$Value = $Form->formValue($InputName); @Values = $Form->formValue($InputName); |
Example |
my @ProductIDs = $Form->formValue('ProductID'); my $ProductID = $Form->formValue('ProductID'); |
Input |
|
Return |
|
formValues
Returns all POST values as hash reference. The values are collected at an array. If the form element is a file-upload element, then the value contains the file name. Use the files method to get the content of the files.
Syntax |
$haValues = $Form->formValues; |
Example |
my @ProductIDs = @{$Form->formValues->{'ProductID'}}; |
Return |
|
method
Returns the request method.
Syntax |
$Method = $Form->method; |
Example |
if( $Form->method eq 'POST' ) { ... } |
Return |
|
new
Creates a new Form object from a given HTTP::Request object.
Syntax |
$Form = DE_EPAGES::WebInterface::API::Form->new( $HttpRequest ); |
Input |
|
Return |
|
queryValue
Returns all query string values for a given field name.
Syntax |
$Value = $Form->queryValue($InputName); @Values = $Form->queryValue($InputName); |
Example |
my $Page = $Form->queryValue('Page'); my @ProductIDs = $Form->queryValue->{'ProductID'}; |
Input |
|
Return |
|
queryValues
Returns all query string values as hash reference. The values are collected in an array, if the query string contains multi-valued keys or not.
Syntax |
$haValues = $Form->queryValues; |
Example |
my $Page = $Form->queryValues->{'Page'}->[0]; my @ProductIDs = $Form->queryValues->{'ProductID'}; |
Return |
|
value
Returns all POST or GET values for a given field name. If the form element is a file-upload element, then the value contains the file name and the content can be determined by the file method. Form input fields overwrite query-sting parameters.
Syntax |
$Value = $Form->value($InputName); @Values = $Form->value($InputName); |
Example |
my @ProductIDs = $Form->value('ProductID'); my $ProductID = $Form->value('ProductID'); |
Input |
|
Return |
|
values
Returns all POST or GET values as hash reference, each value is an array of existing input fields. Form input fields overwrite query-sting parameters.
Syntax |
$haValues = $Form->values; |
Return |
|