Debian Codegraph @

lib/HTML/FormHandler/Widget/Field/Captcha.pm

raw
1 package HTML::FormHandler::Widget::Field::Captcha;
2 # ABSTRACT: Captcha field rendering widget
3 $HTML::FormHandler::Widget::Field::Captcha::VERSION = '0.410002';
4 use Moose::Role;
5 use namespace::autoclean;
6 use HTML::FormHandler::Render::Util ('process_attrs');
7
8
9 sub render_element {
10 my ( $self, $result ) = @_;
11 $result ||= $self->result;
12 return '' if $self->widget eq 'no_widget';
13
14 my $output = '<img src="' . $self->form->captcha_image_url . '"/>';
15 $output .= '<input id="' . $self->id . '" name="';
16 $output .= $self->html_name . '"';
17 $output .= process_attrs($self->element_attributes);
18 $output .= '/>';
19 return $output;
20 }
21
22 sub render {
23 my ( $self, $result ) = @_;
24 $result ||= $self->result;
25 die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result;
26 my $output = $self->render_element( $result );
27 return $self->wrap_field( $result, $output );
28 }
29
30 1;
31
32 __END__
33
34 =pod
35
36 =encoding UTF-8
37
38 =head1 NAME
39
40 HTML::FormHandler::Widget::Field::Captcha - Captcha field rendering widget
41
42 =head1 VERSION
43
44 version 0.410002
45
46 =head1 SYNOPSIS
47
48 Renderer for Captcha field
49
50 =head1 AUTHOR
51
52 FormHandler Contributors - see HTML::FormHandler
53
54 =head1 COPYRIGHT AND LICENSE
55
56 This software is copyright (c) 2017 by Gerda Shank.
57
58 This is free software; you can redistribute it and/or modify it under
59 the same terms as the Perl 5 programming language system itself.
60
61 =cut