lib/Strehler/FormFu/Element/EntitySelect.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 90.4% 38 / 42 CC 3 SCAR 5.9
CC
3
Cov
91%
element
3.1
__ANON__
2.0
BEGIN
1.0
CRAP 1.8
« blib/lib/Strehler/demo/app.pl ↑ Summary lib/Strehler/Element/Role/Slugged.pm »
1 package Strehler::FormFu::Element::EntitySelect;
2 4 $Strehler::FormFu::Element::EntitySelect::VERSION = '1.6.8';
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 extends 'HTML::FormFu::Element::Select';
8  
9 4 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has _element => (
12 is => 'rw',
13 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 4 lazy => 1,
15 );
16  
17 14 ▶after BUILD => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
18 14 my $self = shift;
19  
20 14 $self->filename('input');
21 14 $self->field_filename('select_tag');
22 14 $self->multi_value(1);
23
24 14 return;
25 4 };
26  
27 14 ▶sub element { ## no critic qw(Subroutines::RequireArgUnpacking)
Subroutine element: called CC=3 SCAR=11.2
Pod documented
28 14 my ( $self, $arg ) = @_;
29  
30 14 ▶ return $self->_element if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 14 14
31  
32 14 ▶ if ( defined $arg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg) 14 0 14
33  
34  
35 14 $self->_element( $arg);
36 14 load $arg;
37 14 $self->options($arg->make_select());
38 }
39 14 return $self;
40 }
41  
42 =encoding utf8
43  
44 =head1 NAME
45  
46 Strehler::FormFu::Element::EntitySelect - FormFu Element to allow browsing a Strehler entity with a select box.
47  
48 =head1 DESCRIPTION
49  
50 A Strehler element that you can include in your form configuration to add in an entity edit form a select box populated with the elements of another entity, tipically to manage a foreign key field.
51  
52 This element hasn't the standard HTML::FormFu elements namespace because it makes sense only in a Strehler system.
53  
54 =head1 SYNOPSIS
55  
56 In custom Strehler entity form:
57  
58 - type: '+Strehler::FormFu::Element::EntitySelect'
59 name: otherentity
60 label: Entity
61 element: Site::Element::MyEntity
62  
63 =head1 PARAMETERS
64  
65 =over 4
66  
67 =item element
68  
69 A module derived from Strehler::Element, usually another object managed in Strehler backend. You can use standard entitites (Strehler::Element::Article or Strehler::Element::Image) as well.
70  
71 =back
72  
73 =cut
74  
75 4 1;
« blib/lib/Strehler/demo/app.pl ↑ Summary lib/Strehler/Element/Role/Slugged.pm »