NAME¶
Embperl::Form::Control::table - A table which get data from array of arrays or
array of hashs
SYNOPSIS¶
{
type => 'table',
text => 'blabla',
columns => [['foo', 'Foo item'], 'bar'],
}
DESCRIPTION¶
Used as a base class to create an table control inside an Embperl Form. See
Embperl::Form on how to specify parameters. In most cases you need to
overwrite this class and call the method show_table. show_table takes an
arrayref of hashrefs or arrayref of arrays as parameter which is used as data
to display. In case you have this data directly in %fdat you can use this
control directly.
PARAMETER¶
type
Needs to be 'table'
text
Will be used as label for the control
columns
Arraryref which contains an arrayrefs with definition of columns names. Allows
you to specify multiple rows per data entry. Column definition is either the
key name in the data hashref or an arrayref with the name in the hash ref and
the text to display as heading. Example:
[
[['email', 'E-Mail Address'], ['phone', 'Phone']],
[['foo', 'Foo'], ['bar', 'Bar']],
]
email and phone will be display on the first line with headings 'E-Mail Address'
and 'Phone' and foo and bar will be displayed on the second line for each
entry. In case your data is an array of arrays you have to specifiy the array
index instead of the hash key name.
It is possible to add additional information. One entry might contain the
following entries:
- 0
- Key for into data hashref
- 1
- Text to display
- 2
- Colspan (how many colums this cell should span)
- 3
- If set a control is displayed instead of a text. Must
contain:
radio,<name>,<value> or checkbox,<name>,<value>
- 4
- Display as link. This item contains the name of the key in
the data hashref that holds the href.
- 5
- target for link
- 6
- Name of filter function. The value of the cell is process
through this filter. Filter functions are passed as hashref of subs in the
parameter 'filters' .
line2
Arrayref with names of which the values should concated and displayed below each
entry.
filters
Hashref of coderefs which contains filter functions. The following example shows
one filter called 'date' which passes the data through the perl function
format_date. The value is passed as first argument to the filter function. The
second argument is the column description (see above), the third argument is
the row data and the last argument is the current Embperl request record.
filters =>
{
'date' => sub
{
return format_date ($_[0]) ;
}
}
Author¶
G. Richter (richter at embperl dot org)
See Also¶
perl(1), Embperl, Embperl::Form