| 1 | package Form::Factory::Interface::HTML::Widget::Input; | ||||||||||
| 2 | 1 | $Form::Factory::Interface::HTML::Widget::Input::VERSION = '0.022'; | |||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | extends qw( Form::Factory::Interface::HTML::Widget::Element ); | |||||||||
| 6 | |||||||||||
| 7 | # ABSTRACT: HTML interface widget helper | ||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 1 | has '+tag_name' => ( | |||||||||
| 11 | default => 'input', | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 1 | has type => ( | |||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | isa => 'Str', | ||||||||||
| 17 | required => 1, | ||||||||||
| 18 | default => 'text', | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 1 | has name => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => 'Str', | ||||||||||
| 24 | required => 1, | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 1 | has value => ( | |||||||||
| 28 | is => 'ro', | ||||||||||
| 29 | isa => 'Str', | ||||||||||
| 30 | required => 1, | ||||||||||
| 31 | default => '', | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 1 | has size => ( | |||||||||
| 35 | is => 'ro', | ||||||||||
| 36 | isa => 'Int', | ||||||||||
| 37 | predicate => 'has_size', | ||||||||||
| 38 | ); | ||||||||||
| 39 | |||||||||||
| 40 | 1 | has maxlength => ( | |||||||||
| 41 | is => 'ro', | ||||||||||
| 42 | isa => 'Int', | ||||||||||
| 43 | predicate => 'has_maxlength', | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 1 | has disabled => ( | |||||||||
| 47 | is => 'ro', | ||||||||||
| 48 | isa => 'Bool', | ||||||||||
| 49 | ); | ||||||||||
| 50 | |||||||||||
| 51 | 1 | has readonly => ( | |||||||||
| 52 | is => 'ro', | ||||||||||
| 53 | isa => 'Bool', | ||||||||||
| 54 | ); | ||||||||||
| 55 | |||||||||||
| 56 | 1 | has tabindex => ( | |||||||||
| 57 | is => 'ro', | ||||||||||
| 58 | isa => 'Int', | ||||||||||
| 59 | predicate => 'has_tabindex', | ||||||||||
| 60 | ); | ||||||||||
| 61 | |||||||||||
| 62 | 1 | has alt => ( | |||||||||
| 63 | is => 'ro', | ||||||||||
| 64 | isa => 'Str', | ||||||||||
| 65 | predicate => 'has_alt', | ||||||||||
| 66 | ); | ||||||||||
| 67 | |||||||||||
| 68 | 1 | has checked => ( | |||||||||
| 69 | is => 'ro', | ||||||||||
| 70 | isa => 'Bool', | ||||||||||
| 71 | ); | ||||||||||
| 72 | |||||||||||
| 73 | 134 | ▶ | sub consume_control { | ||||||||
|
Subroutine
consume_control: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 74 | 134 | my ($self, %options) = @_; | |||||||||
| 75 | 134 | my $params = $options{params}; | |||||||||
| 76 | 134 | my $name = $self->name; | |||||||||
| 77 | |||||||||||
| 78 | 134 | return { $name => $params->{ $name } }; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 1 | ▶ | override more_attributes => sub { | ||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=22.6
| |||||||||||
| 82 | 1 | my $self = shift; | |||||||||
| 83 | |||||||||||
| 84 | 1 | my %attributes = ( | |||||||||
| 85 | type => $self->type, | ||||||||||
| 86 | name => $self->name, | ||||||||||
| 87 | value => $self->value, | ||||||||||
| 88 | ); | ||||||||||
| 89 | |||||||||||
| 90 | 1 | ▶ | $attributes{size} = $self->size if $self->has_size; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | 1 | ▶ | $attributes{maxlength} = $self->maxlength if $self->has_maxlength; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 1 | ▶ | $attributes{disabled} = 'disabled' if $self->disabled; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 1 | ▶ | $attributes{readonly} = 'readonly' if $self->readonly; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 1 | ▶ | $attributes{tabindex} = $self->tabindex if $self->has_tabindex; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | 1 | ▶ | $attributes{alt} = $self->alt if $self->has_alt; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 1 | ▶ | $attributes{checked} = 'checked' if $self->checked; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | |||||||||||
| 98 | 1 | return \%attributes; | |||||||||
| 99 | 1 | }; | |||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 103 | |||||||||||
| 104 | __END__ | ||||||||||