| 1 | package HTML::FormHandler::Field::PrimaryKey; | ||||||||||
| 2 | # ABSTRACT: primary key field | ||||||||||
| 3 | 29 | $HTML::FormHandler::Field::PrimaryKey::VERSION = '0.410001'; | |||||||||
| 4 | 29 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 29 | extends 'HTML::FormHandler::Field'; | |||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 29 | has 'is_primary_key' => ( isa => 'Bool', is => 'ro', default => '1' ); | |||||||||
| 9 | 29 | has '+widget' => ( default => 'Hidden' ); | |||||||||
| 10 | 29 | has '+do_label' => ( default => 0 ); | |||||||||
| 11 | 29 | has '+no_value_if_empty' => ( default => 1 ); | |||||||||
| 12 | |||||||||||
| 13 | sub BUILD { | ||||||||||
| 14 | 16 | ▶ | my $self = shift; | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||
| 15 | 16 | ▶ | if ( $self->has_parent ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 16 | ▶ | if ( $self->parent->has_primary_key ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | push @{ $self->parent->primary_key }, $self; | |||||||||
| 18 | } | ||||||||||
| 19 | else { | ||||||||||
| 20 | 16 | $self->parent->primary_key( [ $self ] ); | |||||||||
| 21 | } | ||||||||||
| 22 | } | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 29 | __PACKAGE__->meta->make_immutable; | |||||||||
| 26 | 29 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 29 | 1; | |||||||||
| 28 | |||||||||||
| 29 | __END__ | ||||||||||
| 30 | |||||||||||
| 31 | =pod | ||||||||||
| 32 | |||||||||||
| 33 | =encoding UTF-8 | ||||||||||
| 34 | |||||||||||
| 35 | =head1 NAME | ||||||||||
| 36 | |||||||||||
| 37 | HTML::FormHandler::Field::PrimaryKey - primary key field | ||||||||||
| 38 | |||||||||||
| 39 | =head1 VERSION | ||||||||||
| 40 | |||||||||||
| 41 | version 0.410001 | ||||||||||
| 42 | |||||||||||
| 43 | =head1 SYNOPSIS | ||||||||||
| 44 | |||||||||||
| 45 | This field is for providing the primary key for Repeatable fields: | ||||||||||
| 46 | |||||||||||
| 47 | has_field 'addresses' => ( type => 'Repeatable' ); | ||||||||||
| 48 | has_field 'addresses.address_id' => ( type => 'PrimaryKey' ); | ||||||||||
| 49 | |||||||||||
| 50 | Do not use this field to hold the primary key of the form's main db object (item). | ||||||||||
| 51 | That primary key is in the 'item_id' attribute. | ||||||||||
| 52 | |||||||||||
| 53 | =head1 AUTHOR | ||||||||||
| 54 | |||||||||||
| 55 | FormHandler Contributors - see HTML::FormHandler | ||||||||||
| 56 | |||||||||||
| 57 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 58 | |||||||||||
| 59 | This software is copyright (c) 2017 by Gerda Shank. | ||||||||||
| 60 | |||||||||||
| 61 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 62 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 63 | |||||||||||
| 64 | =cut | ||||||||||