.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::FormHandler::Model::CDBI 3pm" .TH HTML::FormHandler::Model::CDBI 3pm "2022-03-25" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HTML::FormHandler::Model::CDBI \- Class::DBI model class (non\-functioning) .SH "VERSION" .IX Header "VERSION" version 0.40068 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& package MyApplication::Form::User; \& use strict; \& use base \*(AqHTML::FormHandler::Model::CDBI\*(Aq; \& \& \& # Associate this form with a CDBI class \& has \*(Aq+item_class\*(Aq => ( default => \*(AqMyDB::User\*(Aq ); \& \& # Define the fields that this form will operate on \& sub field_list { \& return { \& [ \& name => \*(AqText\*(Aq, \& age => \*(AqPosInteger\*(Aq, \& sex => \*(AqSelect\*(Aq, \& birthdate => \*(AqDateTimeDMYHM\*(Aq, \& ] \& }; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A Class::DBI database model for HTML::FormHandler .PP I don't use \s-1CDBI,\s0 so this module almost certainly doesn't work. It is only being left here as a starting point in case somebody is interested in getting it to work. .PP Patches and tests gratefully accepted. .SH "METHODS" .IX Header "METHODS" .SS "item_class" .IX Subsection "item_class" The name of your database class. .SS "init_item" .IX Subsection "init_item" This is called first time \f(CW$form\fR\->item is called. It does the equivalent of: .PP .Vb 1 \& return $self\->item_class\->retrieve( $self\->item_id ); .Ve .SS "guess_field_type" .IX Subsection "guess_field_type" Pass in a column and assigns field types. Must set \f(CW$self\fR\->item_class to return the related item class. Returns the type in scalar context, returns the type and maybe the related table in list context. .PP Currently returns: .PP .Vb 5 \& DateTime \- for a has_a relationship that isa DateTime \& Select \- for a has_a relationship \& Multiple \- for a has_many \& DateTime \- if the field ends in _time \& Text \- otherwise .Ve .SS "lookup_options" .IX Subsection "lookup_options" Returns a array reference of key/value pairs for the column passed in. Calls \f(CW$field\fR\->label_column to get the column name to use as the label. The default is \*(L"name\*(R". The labels are sorted by Perl's cmp sort. .PP If there is an \*(L"active\*(R" column then only active are included, with the exception being if the form (item) has currently selected the inactive item. This allows existing records that reference inactive items to still have those as valid select options. The inactive labels are formatted with brackets to indicate in the select list that they are inactive. .PP The active column name is determined by calling: .PP .Vb 3 \& $active_col = $form\->can( \*(Aqactive_column\*(Aq ) \& ? $form\->active_column \& : $field\->active_column; .Ve .PP Which allows setting the name of the active column globally if your tables are consistently named (all lookup tables have the same column name to indicate they are active), or on a per-field basis. .PP In addition, if the foreign class is the same as the item's class (or the class returned by item_class) then options pointing to item are excluded. The reason for this is for a table column that points to the same table (self referenced), such as a \*(L"parent\*(R" column. The assumption is that a record cannot be its own parent. .SS "init_value" .IX Subsection "init_value" Populate \f(CW$field\fR\->value with object ids from the \s-1CDBI\s0 object. If the column expands to more than one object then an array ref is set. .SS "validate_model" .IX Subsection "validate_model" Validates fields that are dependent on the model. Currently, \*(L"unique\*(R" fields are checked to make sure they are unique. .PP This validation happens after other form validation. The form already has any field values entered in \f(CW$field\fR\->value at this point. .SS "validate_unique" .IX Subsection "validate_unique" Checks that the value for the field is not currently in the database. .SS "items_same" .IX Subsection "items_same" Returns true if the two passed in cdbi objects are the same object. If both are undefined returns true. .SS "obj_key" .IX Subsection "obj_key" returns a key for a given object, or undef if the object is undefined. .SH "AUTHOR" .IX Header "AUTHOR" FormHandler Contributors \- see HTML::FormHandler .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2017 by Gerda Shank. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.