Scroll to navigation

Form(3pm) User Contributed Perl Documentation Form(3pm)

NAME

Embperl::Form - Embperl Form class

SYNOPSIS

DESCRIPTION

METHODS

new ($controls, $options)

  • $controls

    Array ref with controls which should be displayed inside the form. Each control needs either to be a hashref with all parameters for the control or a control object.

    If hash refs are given it's necessary to specify the "type" parameter, to let Embperl::Form know which control to create.

    See Embperl::Form::Control and Embperl::Form::Control::* for a list of available parameters.

  • $options

    Hash ref which can take the following parameters:

  • formname

    Will be used as name and id attribute of the form. If you have more then one form on a page it's necessary to have different form names to make form validation work correctly.

  • masks

    Contains a hash ref which can specify a set of masks for the controls. A mask is a set of parameter which overwrite the setting of a control. You can specify a mask for a control name (key is name), for a control type (key is *type) or for all controls (key is *).

    Example:

        {
        'info'      => { readonly => 1},
        '*textarea' => { cols => 80 },
        '*'         => { labelclass => 'myclass', labelnowrap => 1}
        }
        

    This will force the control with the name "info" to be readonly, it will force all "textarea" controls to have 80 columns and it will force the label of all controls to have a class of myclass and not to wrap the text.

  • defaults

    Contains a hash ref which can specify a set of defaults for the controls. You can specify a default for a control name (key is name), for a control type (key is *type) or for all controls (key is *).

    Example:

        {
        'info'      => { readonly => 1},
        '*textarea' => { cols => 80 },
        '*'         => { labelclass => 'myclass', labelnowrap => 1}
        }
        

    This will make the control with the name "info" to default to be readonly, it will default all "textarea" controls to have 80 columns and it will set the default class for the labels of all controls to myclass and not to wrap the text.

  • language

    Language setting is used for Embperl::Form::Validate, e.g. 'en' or 'de'

  • charset

    Charset setting is used for Embperl::Form::Validate, e.g. 'utf-8'

  • valign

    valign for control cells. Defaults to 'top' .

  • jsnamespace

    Give the JavaScript Namespace. This allows one to load js files in a top frame or different frame, which will speed up page loading, because the browser does not need to reload the js code on every load.

    Example:

        jsnamespace => 'top'
        
  • classdiv

    Gives the CSS class of the DIV around the form. Default cTableDiv.

  • checkitems

    If set to true, allows one to call the function diff_checkitems after the data is posted and see which form fields are changed.

  • control_packages

    Arrayref with package names to search for form controls. Alternatively you can overwrite the method get_control_packages.

  • datasrc_packages

    Arrayref with package names to search for form data source modules. Alternatively you can overwrite the method get_datasrc_packages.

layout

validate

show

convert_label

Converts the label of a control to the text that should be outputed. By default does return the text or name parameter of the control. Can be overwritten to allow for example internationalization.

$ctrl
Embperl::Form::Control object
$name
optional: name to translate, if not given take $ctrl -> {name}

convert_text

Converts the text of a control to the text that should be outputed. By default does return the text or name parameter of the control. Can be overwritten to allow for example internationalization.

$ctrl
Embperl::Form::Control object

convert_options

Converts the values of a control to the text that should be outputed. By default does nothing. Can be overwritten to allow for example internationalization.

$ctrl
Embperl::Form::Control object
$values
values of the control i.e. values that are submitted
$options
options of the control i.e. text that should be displayed

AUTHOR

G. Richter (richter at embperl dot org)

SEE ALSO

perl(1), Embperl, Embperl::Form::Control

2023-01-22 perl v5.36.0