NAME

HTML::FormEngine::Handler - FormEngine template handler

HANDLERS

default

The default handler is called if the named handler doesn't exist.

With help of the default handler one can nest templates. It expects the name, with which it was called, to be the name of an template. It then reads in this template and processes it. The resulting code is returned.

checked

This handler is used in the select, radio and check template. It first argument is returned if the field was selected. If this argument is not defined, checked is returned. If the field wasn't selected, NULL is returned.

The second argument is the name of the variable in which the value of the field is defined which is submitted if the field was selected. By default the value of this argument is OPT_VAL.

The third argument contains the name of the variable in which the name of the field is stored. With the help of this variable the submitted value of the field is read in to be compared with the value which the field should have if it was selected. So the handler can determine wether the field was selected or not. By default this argument is NAME.

The fourth and last argument contains the name of the variable in which the visible name of the field is stored. The value of this variable is read in to distinguish selection lists. We can expect this value to be unique in the same list. By default this argument is OPTION.

Normally the only important argument is the first one. The others can be important if you want to change variable names.

checked_uniq

This handler is designed for checkboxes. With checked_uniq, you only have to define one name for all options, but you can't use this name again.

The first argument defines the value, which should be returned if a certain option was submitted. By default this is 'checked'.

The second argument defines the name of the variable in which the option values are stored (default: OPT_VAL).

The third argument defines the name of the variable which defines the field name (default: NAME).

confirm_checked

This is a confirm handler. It returns the title of an option if the option was submitted. Therefore the checked handler is called, with the option title as first argument.

The first argument defines the name of the variable in which the option values are stored (default: OPT_VAL). The second argument defines the name of the variable which defines the field name (default: NAME).

The third argument defines the name of the variable which stores the option titles (default: OPTION).

confirm_checked_uniq

This handler is very simalar to confirm_checked. The only difference is that it calls checked_uniq instead of checked.

value

This handler returns the value of the field.

The first argument defines the value which should be returned if the value is empty. By default this is undef.

If the second argument is true (1), the value, which was last returned for this field name, will be returned again instead of trying to fetch the next value.

The third argument is used to tell the handler the name of the variable in which the field name is stored. By default this is NAME.

If the form wasn't submitted, the fields default value is returned.

error

The first argument sets the name of the variable in which the error checks are set. By default this is ERROR.

The second argument sets the name of the variable in which the fields name is stored. By default this is NAME.

The handler calls the defined error checks until an error message is returned or all checks were called. If it retrieves an error message it returns this message, else NULL is returned.

gettext

The arguments, given to this handler, are passed through gettext and then joined together with a spacing blank inbetween. The resulting string is returned.

WRITING A HANDLER

Design

In general, a handler has the following structure:

sub myhandler {
  my($self,$callname,@args) = @_;
  # ... some code ... #
  return $res;
}

$self contains a reference to the FormEngine object.

$callname contains the name or synonym which was used to call the handler. So it is possible to use the same handler for several, similar jobs.

@args contains the arguments which were passed to the handler (see Skin.pm).

Install

You have to edit Config.pm to make your handler available.