| 1 | package HTML::Widget::Element::Fieldset; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use base 'HTML::Widget::Element::Block'; | ||
| 6 | use NEXT; | ||
| 7 | |||
| 8 | __PACKAGE__->mk_accessors('legend'); | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | HTML::Widget::Element::Fieldset - Fieldset Element | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | my $fs = $widget->element( 'Fieldset', 'address' ); | ||
| 17 | $fs->element( 'Textfield', 'street' ); | ||
| 18 | $fs->element( 'Textfield', 'town' ); | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | Fieldset Element. Container element creating a fieldset which can contain | ||
| 23 | other Elements. | ||
| 24 | |||
| 25 | =head1 METHODS | ||
| 26 | |||
| 27 | =head2 new | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | return shift->NEXT::new(@_)->type('fieldset')->class('widget_fieldset'); | ||
| 33 | } | ||
| 34 | |||
| 35 | =head2 legend | ||
| 36 | |||
| 37 | Set a legend for this fieldset. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | sub _pre_content_elements { | ||
| 42 | my ( $self, $w ) = @_; | ||
| 43 | return () unless $self->legend; | ||
| 44 | |||
| 45 | my %args; | ||
| 46 | $args{id} = $self->id($w) . "_legend" if defined $self->name; | ||
| 47 | my $l = HTML::Element->new( 'legend', %args ); | ||
| 48 | |||
| 49 | $l->push_content( $self->legend ); | ||
| 50 | return ($l); | ||
| 51 | } | ||
| 52 | |||
| 53 | =head1 SEE ALSO | ||
| 54 | |||
| 55 | L<HTML::Widget::Element> | ||
| 56 | |||
| 57 | =head1 AUTHOR | ||
| 58 | |||
| 59 | Michael Gray, C<mjg@cpan.org> | ||
| 60 | |||
| 61 | =head1 LICENSE | ||
| 62 | |||
| 63 | This library is free software, you can redistribute it and/or modify it under | ||
| 64 | the same terms as Perl itself. | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | 1; |