Jifty/Web/Form/Field/Button.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 33 CC 4 SCAR 24.0
CC
4
Cov
0%
render_widget
20.0
accessors
2.0
BEGIN
2.0
CRAP 11.0
1 use warnings;
2 use strict;
3
4 package Jifty::Web::Form::Field::Button;
5  
6 use base qw/Jifty::Web::Form::Field/;
7 __PACKAGE__->mk_accessors(qw/button_as_link/);
8  
9  
10 =head1 NAME
11  
12 Jifty::Web::Form::Field::Button - Add buttons to your forms
13  
14 =cut
15  
16 =head1 SUMMARY
17  
18 L<Jifty::Web::Form::Field::Button/> is a L<Jifty::Web::Form::Field>
19  
20 =head1 METHODS
21  
22 =head2 accessors
23  
24 Provide the C<button_as_link> accessor (in addition to
25 L<Jifty::Web::Form::Field>'s default accessors), which controls if the
26 button is reworked in javascript to appear as a link.
27  
28 =cut
29  
30 sub accessors { shift->SUPER::accessors(), 'button_as_link' }
31  
32 =head2 render_widget
33  
34 Renders the button widget.
35  
36 =cut
37  
38 sub render_widget {
39 my $self = shift;
40 my $field = join(
41 ' ',
42 '<input',
43 'type="submit"',
44 'name="' . $self->input_name . '" ',
45 'value="' . Jifty->web->escape(_($self->default_value || $self->label )). '"',
46 ($self->title ? qq( title="@{[$self->title]}") : ''),
47 'id="'. Jifty->web->serial . '"',
48 ($self->key_binding ? qq( accesskey="@{[$self->key_binding]}") : ''),
49 $self->_widget_class('button', ($self->button_as_link ? ("button_as_link") : ())),
50 $self->javascript,
51 ' />',
52 "\n"
53 );
54 Jifty->web->out($field);
55 return '';
56 }
57  
58 1;