macro/editform - macros used for creating sql editing forms
<import src="macro/editform"/>
*sigh* :( Not yet.
Basically, this package lets you create very powerful html forms.
Unless noted otherwise, all the functions creating input elements accept
an optional additional argument which must be a hashref with additional
attribute => value pairs to use in the resulting element (see the similar
functions in the PApp::HTML manpage. The name
attribute can optionally be
overriden.
PApp::multipart_form
). The arguments are treated exactly like
PApp::surl arguments. If it contains SURL_EXEC or similar commands then
these will be executed AFTER the form has been processed.
ef_begin
, but uses PApp::sform
to create the form. This
disables ef_file
widgets with most (if not all browsers).
ef_sbegin
, but uses PApp::cform
to create the form.
ef_cbegin
, just for your convinience.
$S{ef_edit}
is
true). If the argument group
is given, additionally check for the stated
access right.
ef_edit
).
$value
is undef
or omitted, __``Save
Changes'' is used. The rest of the arguments is interpreted in exactly the
same way as the arguments to PApp::surl
, with one exception: if no
destination module is given, the module destination from the ef_begin
macro is used instead of overwriting the destination with the module (as
surl
usually does).
$value
is omitted, __``Restore Values'' is used.
width
(if height
is omitted
ef_text
tries to be intelligent).
fieldref
is evaluated as a normal perl boolean.
fieldref
is compared to ``value'' using
eq
.
ef_constant
for a way to
specify constants that cannot be altered by the user).
values
... can be as many value,
description
pairs as you like.
relation
is an arrayref containing a string (and optionally
arguments) for a select statement that must output key => value
pairs. The values will be used as display labels in an selectbox and the
corresponding key will be stored in the result field. Examples:
ef_relation \$field, ["id, name from manufacturer order by 2"]; ef_relation \$field, ["game_number, game_name from games where game_name like ?", "A%"];
Additional key
=> value
pairs can be appended and will be used.
ef_relation
, but multiple selections are possible. The field
value must be of type ``arrayref'' for this to work. Example:
ef_set \$field, [game => "categories"];
ef_set
, but is based on the ENUM type in sql.
ef_set \$field, [game => "type"];
destination-path
. If destination-path
is a coderef it will be executed
like this:
$res = $callback->($fh, $name, $ct, $cta, $cd);
(see PApp::parse_multipart_form
, which uses the exact same parameters).
The return value can be undefined, in which case the file will be skipped,
a normal string which will be treated as a path to store the file to or
something else, which will be used as a file-handle.
If a destination path is given, the file will be replaced atomically (by first writing a file with a prepended ``~'' and renaming (success case) or unlinking it).
constant
. This is useful when creating
a database row and some of the fields need to be set to a constant
value. The user cannot change this value in any way. Since this function
doesn't output an html tag it doesn't make sense to prepend an initial
hashref with additonal name => value pairs.
Marc Lehmann <pcg@goof.com> http://www.goof.com/pcg/marc/