| 1 | package Rose::HTML::Form::Field::Collection; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use Carp(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 12 | ▶ | use Rose::HTML::Form::Field::Hidden; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use base 'Rose::HTML::Object'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use Rose::HTML::Form::Constants qw(FF_SEPARATOR); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Variables for use in regexes | ||||||||||||||||||||||||||||
| 15 | 12 | our $FF_SEPARATOR_RE = quotemeta FF_SEPARATOR; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 12 | our $VERSION = '0.606'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||
| 20 | # Object data | ||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||
| 24 | ( | ||||||||||||||||||||||||||||
| 25 | 12 | boolean => 'coalesce_hidden_fields', | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 'scalar --get_set_init' => | ||||||||||||||||||||||||||||
| 28 | [ | ||||||||||||||||||||||||||||
| 29 | 'field_rank_counter', | ||||||||||||||||||||||||||||
| 30 | ], | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | array => | ||||||||||||||||||||||||||||
| 33 | [ | ||||||||||||||||||||||||||||
| 34 | 'before_prepare_hooks' => {}, | ||||||||||||||||||||||||||||
| 35 | 'add_before_prepare_hooks' => { interface => 'push', hash_key => 'before_prepare_hooks' }, | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 'after_prepare_hooks' => {}, | ||||||||||||||||||||||||||||
| 38 | 'add_after_prepare_hooks' => { interface => 'push', hash_key => 'after_prepare_hooks' }, | ||||||||||||||||||||||||||||
| 39 | 'clear_prepare_hooks' => { interface => 'clear', hash_key => 'after_prepare_hooks' }, | ||||||||||||||||||||||||||||
| 40 | ], | ||||||||||||||||||||||||||||
| 41 | 12 | ▶ | ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 12 | *add_before_prepare_hook = \&add_before_prepare_hooks; | |||||||||||||||||||||||||||
| 44 | 12 | *add_after_prepare_hook = \&add_after_prepare_hooks; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||
| 47 | # Class methods | ||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub prepare | ||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||
| 52 | 56 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 56 | foreach my $hook ($self->before_prepare_hooks) | |||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 0 | $hook->($self, @_); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 56 | my %args = @_; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 56 | ▶ | unless($args{'form_only'}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 31 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||
| 65 | 103 | $field->prepare(@_); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 56 | foreach my $form ($self->forms) | |||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||
| 71 | 25 | $form->prepare(form_only => 1, @_); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 56 | foreach my $hook ($self->after_prepare_hooks) | |||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||
| 76 | 0 | $hook->($self, @_); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub add_prepare_hook | ||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_prepare_hook: not called CC=5 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if(@_ == 1) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||
| 86 | 0 | $self->add_before_prepare_hook(@_); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | elsif(@_ == 2) | ||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||
| 90 | 0 | my $where = shift; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | unless($where eq 'before' || $where eq 'after') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$where eq "before" or $where eq "after"
MC/DC0%0/2
$where eq "before" or $where eq "after"
$where eq "before"
$where eq "after"
Truth table0%0/3
A or B
A= $where eq "before"B= $where eq "after"
| |||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||
| 94 | 0 | Carp::croak "Illegal prepare hook position: $where"; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my $method = "add_${where}_prepare_hook"; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 100 | 0 | $self->$method(@_); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | else | ||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||
| 104 | 0 | Carp::croak "Incorrect number of arguments to add_prepare_hook()"; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub prepare_hook | ||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
prepare_hook: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 0 | $self->clear_prepare_hooks; | |||||||||||||||||||||||||||
| 112 | 0 | $self->add_prepare_hook(@_); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | BEGIN | ||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||
| 117 | 12 | ▶ | *add_field_type_classes = \&Rose::HTML::Object::add_object_type_classes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 118 | 12 | *field_type_classes = \&Rose::HTML::Object::object_type_classes; | |||||||||||||||||||||||||||
| 119 | 12 | *field_type_class = \&Rose::HTML::Object::object_type_class; | |||||||||||||||||||||||||||
| 120 | 12 | *delete_field_type_class = \&Rose::HTML::Object::delete_object_type_class; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||
| 124 | # Object methods | ||||||||||||||||||||||||||||
| 125 | # | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | sub html | ||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||
| 129 | 1 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
html: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 12 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 1 | ▶ | if($self->has_children || !$self->is_self_closing) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->has_children or not $self->is_self_closing
MC/DC0%0/2
$self->has_children or not $self->is_self_closing
$self->has_children
not $self->is_self_closing
Truth table33%1/3
A or not(B)
A= $self->has_childrenB= not $self->is_self_closing
| |||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||
| 135 | return '<' . $self->html_element . $self->html_attrs_string . '>' . | ||||||||||||||||||||||||||||
| 136 | join('', map | ||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||
| 138 | 1 | ▶ | $_->isa('Rose::HTML::Form::Field') ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | '<div class="field-with-label">' . $_->html_label . | ||||||||||||||||||||||||||||
| 140 | '<div class="field">' . $_->html . '</div></div>' : | ||||||||||||||||||||||||||||
| 141 | $_->html | ||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | $self->children) . | ||||||||||||||||||||||||||||
| 144 | '</' . $self->html_element . '>'; | ||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | return '<' . $self->html_element . $self->html_attrs_string . '>'; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | sub xhtml | ||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||
| 152 | 1 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
xhtml: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 12 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 1 | ▶ | if($self->has_children || !$self->is_self_closing) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->has_children or not $self->is_self_closing
MC/DC0%0/2
$self->has_children or not $self->is_self_closing
$self->has_children
not $self->is_self_closing
Truth table33%1/3
A or not(B)
A= $self->has_childrenB= not $self->is_self_closing
| |||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||
| 158 | return '<' . $self->xhtml_element . $self->xhtml_attrs_string . '>' . | ||||||||||||||||||||||||||||
| 159 | join('', map | ||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||
| 161 | 1 | ▶ | $_->isa('Rose::HTML::Form::Field') ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | '<div class="field-with-label">' . $_->xhtml_label . | ||||||||||||||||||||||||||||
| 163 | '<div class="field">' . $_->xhtml . '</div></div>' : | ||||||||||||||||||||||||||||
| 164 | $_->xhtml | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | $self->children) . | ||||||||||||||||||||||||||||
| 167 | '</' . $self->xhtml_element . '>'; | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | return '<' . $self->xhtml_element . $self->xhtml_attrs_string . ' />'; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 151 | ▶ | sub init_field_rank_counter { 1 } | ||||||||||||||||||||||||||
|
Subroutine
init_field_rank_counter: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | sub increment_field_rank_counter | ||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||
| 177 | 472 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
increment_field_rank_counter: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 178 | 472 | my $rank = $self->field_rank_counter; | |||||||||||||||||||||||||||
| 179 | 472 | $self->field_rank_counter($rank + 1); | |||||||||||||||||||||||||||
| 180 | 472 | return $rank; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | sub make_field | ||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||
| 185 | 624 | ▶ | my($self, $name, $value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
make_field: called CC=10 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 624 | ▶ | return $value if(UNIVERSAL::isa($value, 'Rose::HTML::Form::Field')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 402 | my($type, $args); | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 402 | ▶ | if(ref $value eq 'HASH') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||
| 193 | 330 | ▶ | $type = delete $value->{'type'} or Carp::croak "Missing field type"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 330 | $args = $value; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | elsif(!ref $value) | ||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||
| 198 | 72 | $type = $value; | |||||||||||||||||||||||||||
| 199 | 72 | $args = {}; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | else | ||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||
| 203 | 0 | Carp::croak "Not a Rose::HTML::Form::Field object or hash ref: $value"; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 402 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 402 | ▶ | my $field_class = $class->field_type_class($type) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | or Carp::croak "No field class found for field type '$type'"; | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 402 | ▶ | unless($field_class->can('new')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||
| 213 | 8 | my $error; | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | TRY: | ||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||
| 217 | 8 | local $@; | |||||||||||||||||||||||||||
| 218 | 8 | eval "require $field_class"; | |||||||||||||||||||||||||||
| 219 | 8 | $error = $@; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 8 | ▶ | Carp::croak "Failed to load field class $field_class - $error" if($error); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | # Compound fields require a name | ||||||||||||||||||||||||||||
| 226 | 402 | ▶ | if(UNIVERSAL::isa($field_class, 'Rose::HTML::Form::Field::Compound')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||
| 228 | 46 | $args->{'name'} = $name; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 402 | return $field_class->new(%$args); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | sub invalidate_field_caches | ||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||
| 236 | 625 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
invalidate_field_caches: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 625 | $self->{'field_cache'} = {}; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | sub field | ||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||
| 243 | 3539 | ▶ | my($self, $name, $field) = @_; | ||||||||||||||||||||||||||
|
Subroutine
field: called CC=9 SCAR=23.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 3539 | ▶ | if(@_ == 3) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||
| 247 | 254 | ▶ | unless(UNIVERSAL::isa($field, 'Rose::HTML::Form::Field')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||
| 249 | 0 | $field = $self->make_field($name, $field); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 254 | $field->local_moniker($name); | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 254 | ▶ | if($self->isa('Rose::HTML::Form')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||
| 256 | 0 | $field->parent_form($self); | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | else | ||||||||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||||||||
| 260 | 254 | $field->parent_field($self); | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 254 | $self->_clear_field_generated_values; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 254 | ▶ | unless(defined $field->rank) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | { | ||||||||||||||||||||||||||||
| 267 | 0 | $field->rank($self->increment_field_rank_counter); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 254 | return $self->{'fields'}{$name} = $self->{'field_cache'}{$name} = $field; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 3285 | ▶ | if($self->{'fields'}{$name}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||
| 275 | 3252 | return $self->{'fields'}{$name}; | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 33 | my $sep_pos; | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | # Non-hierarchical name | ||||||||||||||||||||||||||||
| 281 | 33 | ▶ | if(($sep_pos = index($name, FF_SEPARATOR)) < 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||
| 283 | 0 | return undef; # $self->local_field($name, @_); | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | # Check if it's a local compound field | ||||||||||||||||||||||||||||
| 287 | 33 | my $prefix = substr($name, 0, $sep_pos); | |||||||||||||||||||||||||||
| 288 | 33 | my $rest = substr($name, $sep_pos + 1); | |||||||||||||||||||||||||||
| 289 | 33 | $field = $self->field($prefix); | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 33 | ▶ | if(UNIVERSAL::isa($field, 'Rose::HTML::Form::Field::Compound')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||
| 293 | 33 | $field = $field->field($rest); | |||||||||||||||||||||||||||
| 294 | 33 | ▶ | return ($self->{'field_cache'}{$name} = $field) if($field); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | return undef; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | sub find_parent_field | ||||||||||||||||||||||||||||
| 301 | { | ||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my($self, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
find_parent_field: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | # Non-hierarchical name | ||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if(index($name, FF_SEPARATOR) < 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return $self->local_form($name) ? ($self, $name) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | my $parent_form; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | ▶ | while($name =~ s/^([^$FF_SEPARATOR_RE]+)$FF_SEPARATOR_RE//o) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||
| 314 | 0 | my $parent_name = $1; | |||||||||||||||||||||||||||
| 315 | 0 | ▶ | last if($parent_form = $self->local_form($parent_name)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return unless(defined $parent_form); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | return wantarray ? ($parent_form, $name) : $parent_form; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | sub add_fields | ||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||
| 324 | 199 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_fields: called CC=16 SCAR=28.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 199 | my @added_fields; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 199 | ▶ | @_ = @{$_[0]} if(@_ == 1 && ref $_[0] eq 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC100%2/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table100%3/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 199 | ▶ | while(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||
| 332 | 477 | my $arg = shift; | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 477 | ▶ | if(UNIVERSAL::isa($arg, 'Rose::HTML::Form::Field')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | { | ||||||||||||||||||||||||||||
| 336 | 5 | my $field = $arg; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 5 | ▶ | if(refaddr($field) eq refaddr($self)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||
| 340 | 0 | Carp::croak "Cannot nest a field within itself"; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 5 | $field->local_name($field->name); | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 5 | ▶ | if($self->can('form') && $self->form($field->local_name)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->can("form") and $self->form($field->local_name)
MC/DC0%0/2
$self->can("form") and $self->form($field->local_name)
$self->can("form")
$self->form($field->local_name)
Truth table33%1/3
A and B
A= $self->can("form")B= $self->form($field->local_name)
| |||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||
| 347 | 0 | Carp::croak "Cannot add field with the same name as an existing sub-form: ", | |||||||||||||||||||||||||||
| 348 | $field->local_name; | ||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 5 | ▶ | unless(defined $field->rank) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | { | ||||||||||||||||||||||||||||
| 353 | 4 | $field->rank($self->increment_field_rank_counter); | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 5 | $self->field($field->local_name => $field); | |||||||||||||||||||||||||||
| 357 | 5 | push(@added_fields, $field); | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | else | ||||||||||||||||||||||||||||
| 360 | { | ||||||||||||||||||||||||||||
| 361 | 472 | my $field = shift; | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 472 | ▶ | if($self->can('form') && $self->form($arg)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->can("form") and $self->form($arg)
MC/DC100%2/2
$self->can("form") and $self->form($arg)
$self->can("form")
$self->form($arg)
Truth table100%3/3
A and B
A= $self->can("form")B= $self->form($arg)
| |||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||
| 365 | 1 | Carp::croak "Cannot add field with the same name as an existing sub-form: $arg"; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 471 | ▶ | if(UNIVERSAL::isa($field, 'Rose::HTML::Form::Field')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||
| 370 | 105 | ▶ | if(refaddr($field) eq refaddr($self)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||
| 372 | 0 | Carp::croak "Cannot nest a field within itself"; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | else | ||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||
| 377 | 366 | $field = $self->make_field($arg, $field); | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 471 | $field->local_moniker($arg); | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 471 | ▶ | unless(defined $field->rank) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||
| 384 | 468 | $field->rank($self->increment_field_rank_counter); | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 471 | $self->field($arg => $field); | |||||||||||||||||||||||||||
| 388 | 471 | push(@added_fields, $field); | |||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 198 | $self->_clear_field_generated_values; | |||||||||||||||||||||||||||
| 393 | 198 | $self->resync_field_names; | |||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 198 | ▶ | return unless(defined wantarray); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 38 | ▶ | return wantarray ? @added_fields : $added_fields[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 23 | ▶ | sub add_field { shift->add_fields(@_) } | ||||||||||||||||||||||||||
|
Subroutine
add_field: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | sub compare_fields | ||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||
| 403 | 3555 | ▶ | my($self, $one, $two) = @_; | ||||||||||||||||||||||||||
|
Subroutine
compare_fields: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 404 | 12 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 405 | 3555 | $one->name cmp $two->name; | |||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | sub resync_field_names | ||||||||||||||||||||||||||||
| 409 | { | ||||||||||||||||||||||||||||
| 410 | 826 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
resync_field_names: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 826 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 413 | { | ||||||||||||||||||||||||||||
| 414 | 2390 | $field->resync_name; | |||||||||||||||||||||||||||
| 415 | 2390 | ▶ | $field->resync_field_names if($field->isa('Rose::HTML::Form::Field::Compound')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | #$field->name; # Pull the new name through to the name HTML attribute | ||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | sub children | ||||||||||||||||||||||||||||
| 421 | { | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | Carp::croak "Cannot set children() for a pseudo-group ($_[0])" if(@_ > 1); | ||||||||||||||||||||||||||
|
Subroutine
children: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | return wantarray ? shift->fields() : (shift->fields() || []); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
(shift())->fields or []
MC/DC0%0/1
(shift())->fields or []
(shift())->fields
Truth table0%0/2
A
A= (shift())->fields
| |||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | sub field_value | ||||||||||||||||||||||||||||
| 427 | { | ||||||||||||||||||||||||||||
| 428 | 8 | ▶ | my($self, $name) = (shift, shift); | ||||||||||||||||||||||||||
|
Subroutine
field_value: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 8 | ▶ | my $field = $self->field($name) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | or Carp::croak "No field named '$name' in $self"; | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | 8 | ▶ | return $field->input_value(@_) if(@_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 434 | 7 | return $field->internal_value; | |||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 12 | *subfield_value = \&field_value; | |||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | sub subfield_names | ||||||||||||||||||||||||||||
| 440 | { | ||||||||||||||||||||||||||||
| 441 | 20 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
subfield_names: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | 20 | my @names; | |||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 20 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 446 | { | ||||||||||||||||||||||||||||
| 447 | 41 | ▶ | push(@names, $field->name, ($field->can('_subfield_names') ? $field->_subfield_names : ())); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 20 | ▶ | return wantarray ? @names : \@names; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | sub _subfield_names | ||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||
| 455 | 38 | ▶ | map { $_->can('subfield_names') ? $_->subfield_names : $_->name } shift->fields; | ||||||||||||||||||||||||||
|
Subroutine
_subfield_names: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | sub fields | ||||||||||||||||||||||||||||
| 459 | { | ||||||||||||||||||||||||||||
| 460 | 2351 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
fields: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | 2351 | ▶ | if(my $fields = $self->{'field_list'}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||
| 464 | 2183 | ▶ | return wantarray ? @$fields : $fields; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 168 | my $fields = $self->{'fields'}; | |||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | 168 | $self->{'field_list'} = [ grep { defined } map { $fields->{$_} } $self->field_monikers ]; | |||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | 168 | ▶ | return wantarray ? @{$self->{'field_list'}} : $self->{'field_list'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | sub fields_as_children | ||||||||||||||||||||||||||||
| 475 | { | ||||||||||||||||||||||||||||
| 476 | 13 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
fields_as_children: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 13 | ▶ | Carp::croak "Cannot directly set children() for a ", ref($self), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | ". Use fields(), push_children(), pop_children(), etc." if(@_); | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | 13 | my @children; | |||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | 13 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 484 | { | ||||||||||||||||||||||||||||
| 485 | 12 | ▶ | if($field->is_flat_group) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 486 | { | ||||||||||||||||||||||||||||
| 487 | 1 | push(@children, $field->items); | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | else | ||||||||||||||||||||||||||||
| 490 | { | ||||||||||||||||||||||||||||
| 491 | 11 | push(@children, $field); | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 13 | ▶ | return wantarray ? @children : \@children; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 12 | *immutable_children = \&fields_as_children; | |||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | sub num_fields | ||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||
| 502 | 5 | ▶ | my $fields = shift->fields; | ||||||||||||||||||||||||||
|
Subroutine
num_fields: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 503 | 5 | ▶ | return $fields && @$fields ? scalar @$fields : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fields and @$fields
MC/DC0%0/2
$fields and @$fields
$fields
@$fields
Truth table33%1/3
A and B
A= $fieldsB= @$fields
| |||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | sub field_monikers | ||||||||||||||||||||||||||||
| 507 | { | ||||||||||||||||||||||||||||
| 508 | 216 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
field_monikers: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 216 | ▶ | if(my $names = $self->{'field_monikers'}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 511 | { | ||||||||||||||||||||||||||||
| 512 | 48 | ▶ | return wantarray ? @$names : $names; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | 168 | my @info; | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 168 | ▶ | while(my($name, $field) = each %{$self->{'fields'}}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 518 | { | ||||||||||||||||||||||||||||
| 519 | 254 | push(@info, [ $name, $field ]); | |||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | $self->{'field_monikers'} = | ||||||||||||||||||||||||||||
| 523 | 168 | [ map { $_->[0] } sort { $self->compare_fields($a->[1], $b->[1]) } @info ]; | |||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | 168 | ▶ | return wantarray ? @{$self->{'field_monikers'}} : $self->{'field_monikers'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | sub delete_fields | ||||||||||||||||||||||||||||
| 529 | { | ||||||||||||||||||||||||||||
| 530 | 0 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
delete_fields: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 531 | 0 | $self->_clear_field_generated_values; | |||||||||||||||||||||||||||
| 532 | 0 | $self->{'fields'} = {}; | |||||||||||||||||||||||||||
| 533 | 0 | $self->field_rank_counter(undef); | |||||||||||||||||||||||||||
| 534 | 0 | return; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | sub delete_field | ||||||||||||||||||||||||||||
| 538 | { | ||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my($self, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_field: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 0 | ▶ | $name = $name->name if(UNIVERSAL::isa($name, 'Rose::HTML::Form::Field')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 0 | $self->_clear_field_generated_values; | |||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | 0 | delete $self->{'field_cache'}{$name}; | |||||||||||||||||||||||||||
| 546 | 0 | delete $self->{'fields'}{$name}; | |||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | sub clear_fields | ||||||||||||||||||||||||||||
| 550 | { | ||||||||||||||||||||||||||||
| 551 | 493 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
clear_fields: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | 493 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 554 | { | ||||||||||||||||||||||||||||
| 555 | 1787 | $field->clear(); | |||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | sub reset_fields | ||||||||||||||||||||||||||||
| 560 | { | ||||||||||||||||||||||||||||
| 561 | 16 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
reset_fields: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | 16 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 564 | { | ||||||||||||||||||||||||||||
| 565 | 54 | $field->reset(); | |||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | sub _clear_field_generated_values | ||||||||||||||||||||||||||||
| 570 | { | ||||||||||||||||||||||||||||
| 571 | 625 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
_clear_field_generated_values: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 572 | 625 | $self->{'field_list'} = undef; | |||||||||||||||||||||||||||
| 573 | 625 | $self->{'field_monikers'} = undef; | |||||||||||||||||||||||||||
| 574 | 625 | $self->invalidate_field_caches; | |||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | # XXX: This is super-incestuous | ||||||||||||||||||||||||||||
| 577 | 625 | ▶ | if(my $parent_form = $self->parent_form) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||
| 579 | 69 | $parent_form->_clear_field_generated_values; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | sub hidden_field | ||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||
| 585 | 12 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
hidden_field: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | 12 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 588 | 12 | my $name = $self->fq_name; | |||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | return | ||||||||||||||||||||||||||||
| 591 | 12 | ref($self)->object_type_class_loaded('hidden')->new( | |||||||||||||||||||||||||||
| 592 | name => $name, | ||||||||||||||||||||||||||||
| 593 | value => $self->output_value); | ||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | sub hidden_fields | ||||||||||||||||||||||||||||
| 597 | { | ||||||||||||||||||||||||||||
| 598 | 22 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
hidden_fields: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 22 | my @hidden; | |||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 22 | ▶ | if($self->coalesce_hidden_fields) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 603 | { | ||||||||||||||||||||||||||||
| 604 | 6 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 605 | { | ||||||||||||||||||||||||||||
| 606 | 24 | push(@hidden, $field->hidden_field); | |||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||
| 609 | else | ||||||||||||||||||||||||||||
| 610 | { | ||||||||||||||||||||||||||||
| 611 | 16 | foreach my $field ($self->fields) | |||||||||||||||||||||||||||
| 612 | { | ||||||||||||||||||||||||||||
| 613 | 48 | push(@hidden, $field->hidden_fields); | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | 22 | ▶ | return (wantarray) ? @hidden : \@hidden; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | sub html_hidden_field | ||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||
| 622 | 4 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
html_hidden_field: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | 4 | ▶ | if(defined $self->output_value) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 625 | { | ||||||||||||||||||||||||||||
| 626 | 3 | return $self->hidden_field->html_field; | |||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | 1 | return $self->html_hidden_fields; | |||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | sub xhtml_hidden_field | ||||||||||||||||||||||||||||
| 633 | { | ||||||||||||||||||||||||||||
| 634 | 4 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
xhtml_hidden_field: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | 4 | ▶ | if(defined $self->output_value) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 637 | { | ||||||||||||||||||||||||||||
| 638 | 3 | return $self->hidden_field->xhtml_field; | |||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | 1 | return $self->xhtml_hidden_fields; | |||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | sub html_hidden_fields | ||||||||||||||||||||||||||||
| 645 | { | ||||||||||||||||||||||||||||
| 646 | 10 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
html_hidden_fields: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | 10 | my @html; | |||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | 10 | foreach my $field ($self->hidden_fields(@_)) | |||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||
| 652 | 46 | push(@html, $field->html_field); | |||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | 10 | ▶ | return (wantarray) ? @html : join("\n", @html); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | sub xhtml_hidden_fields | ||||||||||||||||||||||||||||
| 659 | { | ||||||||||||||||||||||||||||
| 660 | 6 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
xhtml_hidden_fields: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | 6 | my @xhtml; | |||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 6 | foreach my $field ($self->hidden_fields(@_)) | |||||||||||||||||||||||||||
| 665 | { | ||||||||||||||||||||||||||||
| 666 | 24 | push(@xhtml, $field->xhtml_field); | |||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | 6 | ▶ | return (wantarray) ? @xhtml : join("\n", @xhtml); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | 12 | 1; | |||||||||||||||||||||||||||