Form::...:table(3pm)
π Embperl::Form::Control::table π
okay bestie, listen up β this is the Embperl::Form::Control::table page from the User Contributed Perl Documentation, and it's giving table that gets its data from an array of arrays or an array of hashs. yes, "hashs". we don't fix that, we love her. π«Ά
β¨ NAME β¨
Embperl::Form::Control::table β a table which gets data from an array of arrays or an array of hashs π
πΈ SYNOPSIS πΈ
{
type => 'table',
text => 'blabla',
columns => [['foo', 'Foo item'], 'bar'],
}
π¦ DESCRIPTION π¦
So the vibe here is: this class is a base class, and you use it to create a table control inside an Embperl Form. That's literally its whole job. π
Wanna know how to specify parameters? Go look at Embperl::Form, she has the answers.
In most cases you're gonna need to overwrite this class and call the method show_table. And show_table takes an arrayref of hashrefs or an arrayref of arrays as its parameter, and that's what gets used as the data to display. no cap.
BUT β and this is the slay part β if you already have this data sitting directly in %fdat, you can just use this control directly. no overwriting needed, main character behavior fr fr. β¨
π PARAMETER π
type
Needs to be 'table'. that's it. that's the requirement. periodt.
text
This one gets used as the label for the control. π·οΈ
columns
An arrayref that contains arrayrefs, and those inner arrayrefs are the definition of the column names. This lets you specify multiple rows per data entry β iconic.
Each column definition is either:
- the key name in the data hashref, or
- an arrayref with the name in the hashref and the text to display as the heading
Example time, bestie:
[
[['email', 'E-Mail Address'], ['phone', 'Phone']],
[['foo', 'Foo'], ['bar', 'Bar']],
]
so email and phone get displayed on the first line with the headings 'E-Mail Address' and 'Phone', and foo and bar get displayed on the second line for each entry. cute, right? π
Oh and β if your data is an array of arrays instead, you have to specify the array index instead of the hash key name. different data shape, different rules, iykyk.
Also!! You can add extra info to an entry. One entry might contain these things:
0β key into the data hashref1β text to display2β Colspan (how many columns this cell should span)3β if set, a control is displayed instead of text. Must contain:radio,<name>,<value>orcheckbox,<name>,<value>4β display as a link. This item contains the name of the key in the data hashref that holds thehref.5βtargetfor the link6β name of a filter function. The value of the cell gets processed through this filter. Filter functions are passed as a hashref of subs in the parameter'filters'.
line2
An arrayref with names, and the values of those names get concated and displayed below each entry. yes, "concated". we're keeping it. π
filters
A hashref of coderefs that holds your filter functions. π
Here's an example showing one filter called 'date' which passes the data through the perl function format_date. The value is passed as the 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. so many arguments, so much power. π₯
filters =>
{
'date' => sub
{
return format_date ($_[0]) ;
}
}
π Author π
G. Richter (richter at embperl dot org)
π See Also π
perl(1), Embperl, Embperl::Form
π and that's the whole page bestie, you ate it, go build your table π
This page came to you courtesy of perl v5.34.0 and it was dated 2022-02-06, and yes the man page header calls itself Form::...:table(3pm) β the ellipsis is doing a little mystery moment, we respect it. mwah, bye!! π
β¨
π¦ where this page comes from
- ubuntu jammy: libembperl-perl 2.5.0-16build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms