« Jifty/Plugin/Authentication/Password/Action/ResetLostPassword.pm
↑ Summary
Jifty/Model/Metadata.pm »
| 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; |