NAME

HTML::Widget::Element::RadioGroup - Radio Element grouping

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

RadioGroup Element.

As of version 1.09, an In constraint is no longer automatically added to RadioGroup elements. Use "constrain_values" to provide this functionality.

METHODS

comment

Add a comment to this Element.

label

This label will be placed next to your Element.

legend

Because the RadioGroup is placed in a fieldset tag, you can also set a </legend> value. Note, however, that if you want the RadioGroup to be styled the same as other elements, the "label" setting is recommended.

values

List of form values for radio checks. Will also be used as labels if not otherwise specified via labels.

checked

value

Set which radio element will be pre-set to "checked".

"value" is provided as an alias for "checked".

labels

The labels for corresponding "values".

constrain_values

If true, an In constraint will automatically be added to the widget, using the values from "values".

retain_default

If true, 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.

new

prepare

containerize

id

CSS

Horizontal Alignment

To horizontally align the radio buttons with the label, use the following CSS.

.radiogroup > label {
  display: inline;
}

Changes in version 1.10

A RadioGroup is now rendered using a fieldset tag, instead of a label tag. This is because the individual radio buttons also use labels, and the W3C xhtml specification forbids nested label tags.

To ensure RadioGroup elements are styled similar to other elements, you must change any CSS label definitions to also target the RadioGroup's class. This means changing any label { ... } definition to label, .radiogroup_fieldset { ... }. 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 other elements.

If you find the RadioGroup fieldset picking up styles intended only for other fieldsets, you can either override those styles with your label, .radiogroup_fieldset { ... } definition, or you can change your fieldset { ... } definition to .widget_fieldset{ ... } to specifically target any Fieldset elements other than the RadioGroup's.

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. To ensure that any labels_with_errors styles are properly displayed around RadioGroups, you must add display: block; to your .labels_with_errros{ ... } definition.

SEE ALSO

HTML::Widget::Element

AUTHOR

Jess Robinson

Yuval Kogman

LICENSE

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.