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.

value

This handler returns the value of the field. Therefore the handler needs to know the name of the field. The first 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.

WRITING A HANDLER

Design

In general, a handler has the following structure:

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

$self contains a reference to the FormEngine object.

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

$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.

Install

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