Form(3pm)

πŸ“¦
version 2.5.0 Β· 2 versions
, in ubuntu jammy

πŸ’– Form(3pm) β€” the Embperl::Form glow-up πŸ’–

okay so bestie, welcome to Embperl::Form, aka the Embperl Form class. this is the page for it, and it's giving "build me a whole form, queen" energy. let's get into it 🫢


✨ SYNOPSIS ✨

soooo... there's literally nothing here. the synopsis is empty. iconic of it, honestly. no sample code, no teaser, just vibes πŸ’…


🌸 DESCRIPTION 🌸

also empty!! the description said "no thoughts, head empty" and honestly? we respect it. everything you need lives down in METHODS. keep scrolling, babe πŸ¦‹


πŸ‘‘ METHODS πŸ‘‘

new ($controls, $options)

the constructor, the main character, the one who gets the party started ✨ it takes two things:

  • $controls β€” an array ref with all the controls that should show up inside the form. every single control in there has to either be a hashref carrying all the parameters for that control, or be an actual control object. and if you're passing plain hashrefs, you have to specify the "type" parameter, otherwise Embperl::Form has no clue which control to make for you. for the full list of parameters you can use, go peek at Embperl::Form::Control and Embperl::Form::Control::* πŸŽ€
  • $options β€” a hash ref, and it can take all of these:
    • formname β€” gets used as the name and id attribute of the form. lowkey important: if you've got more than one form on a page, you need different form names or form validation will not work correctly. periodt.
    • masks β€” holds a hash ref that can specify a set of masks for the controls. a mask is a set of parameters that overwrite the settings of a control. you can give a mask for a control name (the key is the name), for a control type (the key is *type), or for all controls (the key is *).

example:

{
'info'      => { readonly => 1},
'*textarea' => { cols => 80 },
'*'         => { labelclass => 'myclass', labelnowrap => 1}
}

what this does: forces the control named "info" to be readonly, forces every "textarea" control to have 80 columns, and forces the label of all controls to have a class of myclass and to not wrap the text. slay πŸ”₯

  • defaults β€” holds a hash ref that can specify a set of defaults for the controls. same deal as masks: you can set a default for a control name (key is the name), for a control type (key is *type), or for all controls (key is *).

example:

{
'info'      => { readonly => 1},
'*textarea' => { cols => 80 },
'*'         => { labelclass => 'myclass', labelnowrap => 1}
}

what this one does: makes the control named "info" default to readonly, defaults all "textarea" controls to 80 columns, and sets the default class for the labels of all controls to myclass plus no text wrapping ✨

  • language β€” the language setting, used for Embperl::Form::Validate, like 'en' or 'de' 🌈
  • charset β€” the charset setting, used for Embperl::Form::Validate, like 'utf-8'
  • valign β€” the valign for control cells. defaults to 'top' πŸ’œ
  • jsnamespace β€” gives the JavaScript Namespace. this lets you load js files in a top frame or a different frame, which speeds up page loading, because the browser doesn't have to reload the js code on every load. chef's kiss efficiency 🧚

example:

jsnamespace => 'top'
  • classdiv β€” gives the CSS class of the DIV around the form. default is cTableDiv πŸŽ€
  • checkitems β€” if you set this to true, it lets you call the function diff_checkitems after the data is posted, so you can see which form fields changed. detective mode activated πŸ”
  • control_packages β€” an arrayref with package names to search for form controls. alternatively, you can overwrite the method get_control_packages.
  • datasrc_packages β€” an arrayref with package names to search for form data source modules. alternatively, you can overwrite the method get_datasrc_packages.

layout

just a name, bestie. no extra deets on this one in the page. it's there, it exists, it's living its truth πŸ’…

validate

same situation β€” it's listed, and that's all the page tells us. no cap.

show

also just listed. short and mysterious, love that for it πŸ¦‹

convert_label

converts the label of a control into the text that should be outputted. by default it returns the text or name parameter of the control. you can overwrite it so you can do stuff like internationalization 🌍

  • $ctrl β€” an Embperl::Form::Control object
  • $name β€” optional: the name to translate. if it's not given, it takes $ctrl -> {name}

convert_text

converts the text of a control into the text that should be outputted. by default it returns the text or name parameter of the control. overwrite it if you wanna do things like internationalization πŸ’–

  • $ctrl β€” an Embperl::Form::Control object

convert_options

converts the values of a control into the text that should be outputted. by default it does nothing at all (respect, honestly). overwrite it if you wanna do things like internationalization ✨

  • $ctrl β€” an Embperl::Form::Control object
  • $values β€” values of the control, i.e. the values that are submitted
  • $options β€” options of the control, i.e. the text that should be displayed

πŸ’œ AUTHOR πŸ’œ

G. Richter (richter at embperl dot org) β€” thank you for your service, legend πŸ‘‘


🌈 SEE ALSO 🌈

perl(1), Embperl, Embperl::Form::Control β€” go read these next, bestie, they're the supporting cast 🫢


and that's the whole page, babe!! this was pulled from perl v5.34.0, dated 2022-02-06, and it's part of the User Contributed Perl Documentation. mwah πŸ’‹ go build something gorgeous ✨

πŸ“¦ where this page comes from