CGI::T...:Button(3pm)

πŸ“¦
version 1.111 Β· 2 versions
  • 1.111 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.111 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CGI::Test::Form::Widget::Button β€” bestie edition πŸ’–

okay so you found the CGI::Test::Form::Widget::Button page in the User Contributed Perl Documentation, and honestly? it's giving "abstract representation of a button" and nothing less. periodt.


✨ NAME ✨

CGI::Test::Form::Widget::Button β€” an abstract representation of a button πŸŽ€


🌸 SYNOPSIS 🌸

# Inherits from CGI::Test::Form::Widget

that's it bestie, that's the whole synopsis. it just inherits and vibes. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this class is the abstract representation of a button. like, any button. a submit button? yes. an image button? yes. a reset button? yes. a plain button? also yes. all of them live here, it's giving very inclusive. πŸ‘‘

so how do you actually press one? you call press() on it. that's the move. and what do you get back?

  • a new page, as a CGI::Test::Page object πŸ”₯
  • or undef, if pressing had no round-trip effect

that's the whole deal. no cap.


πŸ’œ INTERFACE πŸ’œ

the interface is literally the same as the one described in CGI::Test::Form::Widget, with the following additions β€” so go read that one too, bestie, iykyk.


πŸ“ Attributes

  • is_pressed β€” true when the button is pressed. that's it. that's the whole attribute. iconic.

πŸ’… Attribute Setting

  • press β€” press the button, setting is_pressed to true. and then it gets spicy depending on what kind of button you're dealing with:
    • if the button is a reset button (is_reset is true), then all widgets are reset to their initial state, and undef is returned. clean slate energy ✨
    • if the button is a submit button (is_submit is true), then a GET/POST request is issued as appropriate, and the reply is made available through a CGI::Test::Page object. we love a round trip 🫢
    • otherwise?? the button pressing is ignored, a warning is issued from the perspective of the caller, via carp, and undef is returned. 🫠
heads up: that last one is the "nothing happened and we're telling you about it" path. no request, no page, just a carp and a undef. don't say we didn't warn you (because technically we did, via carp).

🌈 Widget Classification Predicates

there is an additional set of predicates to distinguish between the various buttons, so you can vibe check any button you meet:

  • is_plain β€” returns true for a plain button, i.e. a button that has no submit/reset effects. usually, those buttons are linked to a script, but CGI::Test does not support scripting yet. 😭
  • is_reset β€” returns true for reset buttons.
  • is_submit β€” returns true for submit buttons, whether they are really shown as buttons or as images. a submit button will cause an HTTP request to be issued in response to its being pressed.

🧚 Miscellaneous Features

okay so although documented, these features are more targetted for internal use... you've been warned, bestie. πŸ™ˆ

  • set_is_pressed flag β€” change the pressed status of the button, to the value of flag. it does not raise any other side effect, like submitting an HTTP request if the button is a submit button. so it's just... the flag. that's it. no side quests. πŸ’€
you should probably use the press convenience routine instead of calling this feature directly. fr fr, press is the main character here. πŸ‘‘

πŸ‘‘ AUTHORS πŸ‘‘

  • the original author is Raphael Manfredi.
  • Steven Hilton was long time maintainer of this module.
  • current maintainer is Alexander Tokarev <tokarev@cpan.org>.

🌟 SEE ALSO 🌟


and that's the whole page, bestie!! πŸŽ€ this one shipped as part of perl v5.34.0, dated 2022-06-10, and in the User Contributed Perl Documentation section. go press a button (with press(), preferably). mwah πŸ’–βœ¨πŸ¦‹