| 1 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package HTML::FormFu::Element::ContentButton; | ||||||||||
| 4 | 6 | $HTML::FormFu::Element::ContentButton::VERSION = '2.09'; | |||||||||
| 5 | # ABSTRACT: Button form field containing markup | ||||||||||
| 6 | |||||||||||
| 7 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 6 | ▶ | use MooseX::Attribute::Chained; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 6 | extends "HTML::FormFu::Element"; | |||||||||
| 10 | 6 | with 'HTML::FormFu::Role::Element::Field', | |||||||||
| 11 | 'HTML::FormFu::Role::Element::SingleValueField'; | ||||||||||
| 12 | |||||||||||
| 13 | 6 | ▶ | use HTML::FormFu::Util qw( xml_escape process_attrs ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 6 | __PACKAGE__->mk_output_accessors(qw( content )); | |||||||||
| 16 | |||||||||||
| 17 | 6 | has field_type => ( | |||||||||
| 18 | is => 'rw', | ||||||||||
| 19 | default => 'button', | ||||||||||
| 20 | lazy => 1, | ||||||||||
| 21 | traits => ['Chained'], | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 6 | ▶ | after BUILD => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 6 | my ( $self, $args ) = @_; | |||||||||
| 26 | |||||||||||
| 27 | 6 | $self->layout_field_filename('field_layout_contentbutton_field'); | |||||||||
| 28 | |||||||||||
| 29 | 6 | return; | |||||||||
| 30 | 6 | }; | |||||||||
| 31 | |||||||||||
| 32 | 9 | ▶ | sub render_data_non_recursive { | ||||||||
|
Subroutine
render_data_non_recursive: called CC=2 SCAR=7.1
| |||||||||||
| 33 | 9 | my ( $self, $args ) = @_; | |||||||||
| 34 | |||||||||||
| 35 | 9 | ▶ | my $render = $self->SUPER::render_data_non_recursive( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | { field_type => $self->field_type, | ||||||||||
| 37 | content => xml_escape( $self->content ), | ||||||||||
| 38 | $args ? %$args : (), | ||||||||||
| 39 | } ); | ||||||||||
| 40 | |||||||||||
| 41 | 9 | return $render; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 8 | ▶ | sub _string_field { | ||||||||
|
Subroutine
_string_field: called CC=4 SCAR=13.9
| |||||||||||
| 45 | 8 | my ( $self, $render ) = @_; | |||||||||
| 46 | |||||||||||
| 47 | # content_button template | ||||||||||
| 48 | |||||||||||
| 49 | 8 | my $html = "<button"; | |||||||||
| 50 | |||||||||||
| 51 | 8 | ▶ | if ( defined $render->{nested_name} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 7 | $html .= sprintf qq{ name="%s"}, $render->{nested_name}; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 8 | $html .= sprintf qq{ type="%s"}, $render->{field_type}; | |||||||||
| 56 | |||||||||||
| 57 | 8 | ▶ | if ( defined $render->{value} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 2 | $html .= sprintf qq{ value="%s"}, $render->{value}; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | $html .= sprintf "%s>%s</button>", | ||||||||||
| 62 | process_attrs( $render->{attributes} ), | ||||||||||
| 63 | 8 | ▶ | ( defined $render->{content} ? $render->{content} : '' ), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | ; | ||||||||||
| 65 | |||||||||||
| 66 | 8 | return $html; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||
| 70 | |||||||||||
| 71 | 6 | 1; | |||||||||
| 72 | |||||||||||
| 73 | __END__ | ||||||||||