1HTML::FormFu::ConstrainUts:e:rDBCIoCn:t:rUinbiuqtueedH(T3PM)eLr:l:FDoorcmuFmue:n:tCaotnisotnraint::DBIC::Unique(3)
2
3
4

NAME

6       HTML::FormFu::Constraint::DBIC::Unique - unique constraint for
7       HTML::FormFu::Model::DBIC
8

VERSION

10       version 2.03
11

SYNOPSIS

13           $form->stash->{schema} = $dbic_schema; # DBIC schema
14
15           $form->element('text')
16                ->name('email')
17                ->constraint('DBIC::Unique')
18                ->resultset('User')
19                ;
20
21
22           $form->stash->{context} = $c; # Catalyst context
23
24           $form->element('text')
25                ->name('email')
26                ->constraint('DBIC::Unique')
27                ->model('DBIC::User')
28                ;
29
30           $form->element('text')
31                ->name('user')
32                ->constraint('DBIC::Unique')
33                ->model('DBIC')
34                ->resultset('User')
35                ;
36
37
38           or in a config file:
39           ---
40           elements:
41             - type: text
42               name: email
43               constraints:
44                 - Required
45                 - type: DBIC::Unique
46                   model: DBIC::User
47             - type: text
48               name: user
49               constraints:
50                 - Required
51                 - type: DBIC::Unique
52                   model: DBIC::User
53                   column: username
54

DESCRIPTION

56       Checks if the input value exists in a DBIC ResultSet.
57

METHODS

59   model
60       Arguments: $string # a Catalyst model name like 'DBIC::User'
61
62   resultset
63       Arguments: $string # a DBIC resultset name like 'User'
64
65   self_stash_key
66       reference to a key in the form stash. if this key exists, the
67       constraint will check if the id matches the one of this element, so
68       that you can use your own name.
69
70   id_field
71       Use this key to define reference field which consist of primary key of
72       resultset. If the field exists (and $self_stash_key not defined), the
73       constraint will check if the id matches the primary key of row object:
74
75           ---
76           elements:
77             - type:  Hidden
78               name:  id
79               constraints:
80                 - Required
81
82             - type:  Text
83               name:  value
84               label: Value
85               constraints:
86                 - Required
87                 - type:       DBIC::Unique
88                   resultset:  ControlledVocab
89                   id_field:   id
90
91   others
92       Use this key to manage unique compound database keys which consist of
93       more than one column. For example, if a database key consists of
94       'category' and 'value', use a config file such as this:
95
96           ---
97           elements:
98             - type:  Text
99               name:  category
100               label: Category
101               constraints:
102                 - Required
103
104             - type:  Text
105               name:  value
106               label: Value
107               constraints:
108                 - Required
109                 - type:       DBIC::Unique
110                   resultset:  ControlledVocab
111                   others:     category
112
113   method_name
114       Name of a method which will be called on the resultset. The method is
115       passed two argument; the value of the field, and the primary key value
116       (usually `id`) of the record in the form stash (as defined by
117       self_stash_key). An example config might be:
118
119           ---
120           elements:
121             - type: text
122               name: user
123               constraints:
124                 - Required
125                 - type: DBIC::Unique
126                   model: DBIC::User
127                   method_name: is_username_available
128
129   SEE ALSO
130       Is a sub-class of, and inherits methods from HTML::FormFu::Constraint
131
132       HTML::FormFu::FormFu
133

AUTHOR

135       Jonas Alves "jgda@cpan.org"
136

LICENSE

138       This library is free software, you can redistribute it and/or modify it
139       under the same terms as Perl itself.
140
141
142
143perl v5.32.0                      2020H-T0M7L-:2:8FormFu::Constraint::DBIC::Unique(3)
Impressum