HTML::S...::Field(3)

πŸ“¦
version 1.09 Β· 2 versions
, in fedora 43

πŸ’– HTML::S...::Field(3) β€” the group chat version πŸ’–

okay bestie, so this is HTML::SuperForm::Field, the base class for literally every HTML form field object in the HTML::SuperForm universe πŸ‘‘ it's the blueprint, the main character, the one everyone else inherits from. (yes the manual is called HTML::S...::Field(3), the terminal just truncates it, iconic behaviour honestly πŸ’…)


✨ NAME ✨

HTML::SuperForm::Field β€” HTML form field base class. that's it, that's the vibe 🌸


🌈 SYNOPSIS 🌈

here's what subclassing her actually looks like, no cap:

package myForm::SuperDuper;

use base 'HTML::SuperForm::Field';

sub init {}
sub prepare {}

sub to_html {
    my $self = shift;

    my $tag = qq|For some reason this text makes|;
       $tag.= qq|the field super duper|
       $tag.= qq|<input type="text" name="| . $self->name . '"';
       $tag.= qq| value="| . $self->value . '"';
       $tag.= '/' if $self->well_formed;
       $tag.= '>';

    return $tag;
}

1;

(not me noticing the missing semicolons up in there πŸ’€ that's the source, we do not touch it, periodt.)


πŸ¦‹ DESCRIPTION πŸ¦‹

she is the base class for all the HTML form field objects. everything else is her daughter. slay. πŸ’…


πŸ’œ METHODS πŸ’œ

πŸŽ€ CONSTRUCTOR πŸŽ€

  • new($form, %args), new($form, \%args), new(%args), new(\%args) β€” the classic four-flavour constructor situation. here's the tea:
    • $form is the HTML::SuperForm object you wanna associate the field with 🫢
    • %args usually has the following (and btw each one is also a method so you can read its value back later, iykyk):
    • name() β€” the name of the field. literally just her name.
    • default() β€” the default value to use before data has been submitted, or if the form isn't sticky. the backup bestie.

other possible arguments include:

  • sticky() β€” determines whether the field is sticky or not 🍯 defaults to whatever the form object's sticky flag is set to. if no form object is specified, it defaults to false.
  • fallback() β€” determines whether the field's value "falls back" to the default if the field is sticky but no data has been submitted for the field. defaults to whatever the form object's fallback flag is set to. if no form object is specified, it defaults to false.
  • well_formed() β€” determines whether the HTML generated is well-formed or not. if true, a slash gets added to the end of non-container tags (i.e. <input type="text name="my_text"/>). attributes such as multiple, readonly, disabled, selected, and checked are also set equal to true values instead of being left alone (i.e. <input type="checkbox" checked="checked"> rather than just <input type="checkbox" checked>). so polite, so proper ✨
  • values_as_labels(), value_as_label() β€” determines whether the value specifed by value or values is used as a label if no label is specified. default is true.
  • disabled() β€” determines whether the field is disabled or not. sad girl hours πŸ™ˆ

arguments not used by all the fields also include:

  • multiple() β€” determines whether a field can have multiple values selected. only Select uses this feature.
  • readonly() β€” determines whether a field is readonly. used by fields such as Text and Textarea.

⭐ init($config) ⭐

this method is the very first thing called in HTML::SuperForm::Field's constructor. subclasses of HTML::SuperForm::Field should override this method to manipulate the parameters passed in before processing them. an example lives in HTML::SuperForm::Field::Checkbox πŸ‘‘

🌸 prepare() 🌸

this method is the very last thing called in HTML::SuperForm::Field's constructor. subclasses of HTML::SuperForm::Field should override this method to add extra information to the object for later use. an example of its use is in the documentation for HTML::SuperForm under the section EXAMPLES. it's giving pre-game ritual πŸ’–

πŸ”₯ to_html() πŸ”₯

this method returns the string representation of your field. when the object is used in string context, this method is called to generate the string. subclasses of HTML::SuperForm::Field should override this method display a default layout. all of the basic fields that come with HTML::SuperForm have this method, so look at them for examples πŸ‘€ the Counter example in HTML::SuperForm's documentation could also be helpful. go read, bestie, it's worth it 🫢


🌈 SEE ALSO 🌈

  • HTML::SuperForm::Field::Text
  • HTML::SuperForm::Field::Textarea
  • HTML::SuperForm::Field::Select
  • HTML::SuperForm::Field::Checkbox
  • HTML::SuperForm::Field::Radio
  • HTML::SuperForm::Field::CheckboxGroup
  • HTML::SuperForm::Field::RadioGroup

the whole friend group, all together, we love to see it πŸ’…βœ¨


πŸ‘‘ AUTHOR πŸ‘‘

John Allwine <jallwine86@yahoo.com> β€” the icon, the legend, the one who wrote this before most of us could read. respect. 🫑


πŸ’€ POD ERRORS πŸ’€

hey! the above document had some coding errors, which are explained below:

  • Around line 495:
    • '=item' outside of any '=over'
  • Around line 516:
    • You forgot a '=back' before '=head1'
not the POD parser dragging the docs in front of everyone 😭 it's fine, we still love her, flaws and all.

and that's the whole page, bestie πŸŽ€ this came to you from perl v5.42.0, dated 2025-07-25, and that's the HTML::S...::Field(3) manual β€” read it, love it, subclass it responsibly. mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from