HTML::...ioGroup(3pm)
π NAME π
HTML::Widget::Element::RadioGroup β Radio Element grouping π
Okay bestie, quick vibe check: this page lives in the User Contributed Perl Documentation (that's the 3pm section, iykyk). The header up top is all squished down to HTML::...ioGroup(3pm) but the real, full name of the thing is HTML::Widget::Element::RadioGroup and we're gonna treat her with the respect she deserves π
β¨ SYNOPSIS β¨
my $e = $widget->element( 'RadioGroup', 'foo' );
$e->comment('(Required)');
$e->label('Foo'); # label for the whole thing
$e->values([qw/foo bar gorch/]);
$e->labels([qw/Fu Bur Garch/]); # defaults to ucfirst of values
$e->comments([qw/funky/]); # defaults to empty
$e->value("foo"); # the currently selected value
$e->constrain_values(1);
π¦ DESCRIPTION π¦
It's a RadioGroup Element. That's the whole thing, that's the job π«Ά
But here's the important lore, no cap: as of version 1.09, an In constraint is no longer automatically added to RadioGroup elements. So if you want that behaviour back, you gotta go get it yourself with "constrain_values". Periodt π
πΈ METHODS πΈ
comment
Add a comment to this Element. Cute little note, love that for you π¬
label
This label will be placed next to your Element. Right there. Beside it. Besties π
legend
So here's the thing β because the RadioGroup gets placed inside a "fieldset" tag, you can also set a </legend> value. π
But heads up babes: if you want your RadioGroup to be styled the same as your other elements, the "label" setting is the one that's recommended. Don't fight it π
values
List of form values for radio checks. π― These will also get used as labels if you didn't otherwise specify them via labels.
checked / value
Set which radio element will be pre-set to "checked". β
And "value" is provided as an alias for "checked" β same energy, different name, we stan a flexible queen π
labels
The labels for the corresponding "values". Matchy matchy π
constrain_values
If true, an In constraint will automatically be added to the widget, using the values from "values". That's the auto-magic you were missing since 1.09, babes β¨
retain_default
If true, this overrides the default behaviour β so that after a field is missing from the form submission, the xml output will contain the default value, rather than be empty. No more sad empty output ππ
new
prepare
containerize
id
These ones are listed in the docs but they didn't get a blurb of their own here π β no description given, so I'm not gonna make one up (that would be lying and lying is not the vibe).
π CSS π
Horizontal Alignment
To horizontally align the radio buttons with the label, use the following CSS:
.radiogroup > label {
display: inline;
}
Slay, aligned, immaculate β¨
Changes in version 1.10
Okay so big glow-up alert: a RadioGroup is now rendered using a "fieldset" tag, instead of a "label" tag. Why? Because the individual radio buttons also use labels, and the W3C xhtml specification forbids nested "label" tags. Rude of the spec but okay, we adapt π
To make sure RadioGroup elements are styled similar to your other elements, you must change any CSS "label" definitions to also target the RadioGroup's class. That means changing any label { ... } definition into label, .radiogroup_fieldset { ... }. And if you're using the "simple.css" example file, testing with firefox shows you'll also need to add margin: 0em; to that definition to get the label to line up with the other elements. Details matter, bestie π
If you find the RadioGroup "fieldset" picking up styles that were intended only for other fieldsets, you've got two options, pick your fighter:
- override those styles with your
label, .radiogroup_fieldset { ... }definition, or - change your
fieldset { ... }definition to.widget_fieldset{ ... }so it specifically targets any Fieldset elements other than the RadioGroup's.
And here's the old-behaviour tea β: previously, if there were any errors, the label tag was given the classname "labels_with_errors". Now, if there's errors, the RadioGroup "fieldset" tag is wrapped in a "span" tag which is given the classname "labels_with_errors". So to ensure that any "labels_with_errors" styles are properly displayed around RadioGroups, you must add display: block; to your .labels_with_errros{ ... } definition.
Note: yes, that's spelled .labels_with_errros in the original β with the lil typo and everything. Copy it exactly, do not "fix" it, do not be a hero π
π SEE ALSO π
HTML::Widget::Element
Go read that one next, it's giving main character energy π
π AUTHOR π
- Jess Robinson
- Yuval Kogman
Legends, both of them, we say thank you ππ
π LICENSE π
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Free as in freedom, babes π¦
And that's the whole page, bestie!! π This little masterpiece came to you courtesy of perl v5.36.0, dated 2023-08-10, from that HTML::...ioGroup(3pm) page in the User Contributed Perl Documentation. Mwah, go build something cute with it π
β¨π
π¦ where this page comes from
- debian trixie: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-widget-perl 1.11-7 Β· 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