.\" 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::Manual::Rendering 3pm" .TH HTML::FormHandler::Manual::Rendering 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::Manual::Rendering \- how to render with FormHandler .SH "VERSION" .IX Header "VERSION" version 0.40068 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Manual Index .PP Rendering can be done in many different ways, from forms rendered entirely in templates with no information from FormHandler (except possibly the fill-in-the-form values) to forms that are completely rendered by FormHandler. .SH "DESCRIPTION" .IX Header "DESCRIPTION" For most situations, something in between hand-built and completely generated will probably be the best solution. For admin forms that don't need a lot of styling or special \s-1HTML,\s0 FormHandler's automatic rendering may be appropriate. FormHandler rendering may also be a good solution if you have enough forms that putting time into creating rendering widgets and themes is worthwhile. .PP The automatic rendering is also useful when developing a new form. You can get an idea of what it looks like, and then customize it. .PP Another situation in which FormHandler rendering may be useful is when the form is complex enough that working in Perl is a better idea than putting lots of logic into templates. .PP All of the rendering is designed to be easily replaced with elements of your own, or to be replaced entirely. You can create your own rendering 'widgets' and load them into the fields by designating the directory in the \&'widget_name_space'. You could also create a completely separate renderer that's a separate object or class that takes a form object, or a role that is applied to your form. .PP Note that unless you set 'no_widgets' in the form, the rendering roles are automatically applied. You don't need to include anything else, unless you want to use a different renderer. .SS "Mostly templates" .IX Subsection "Mostly templates" The names of your fields must match the names of your FormHandler fields. If you use compound fields, you must use the FormHandler naming convention. .PP Form used in examples: .PP .Vb 3 \& package MyApp::Form::Example; \& use HTML::FormHandler::Moose; \& extends \*(AqHTML::FormHandler\*(Aq; \& \& has_field \*(Aqfoo\*(Aq; \& has_field \*(Aqbar\*(Aq; \& has_field \*(Aqsave\*(Aq => ( type => \*(AqSubmit\*(Aq ); .Ve .PP If you have existing forms in templates or just prefer them, you can use the 'fill\-in\-form' values provided with the form's 'fif' function. .PP .Vb 11 \& my $form = MyApp::Form::Example\->new; \& $form\->process( params => $params ); \& $c\->stash( fif => $form\->fif ); \& ... \&
.Ve .PP If you are looking for an easy way to get your fields to line up in an evenly spaced manner, all uniformly aligned, and to do so without using templates or tables, you can externally style the default FormHandler output with the following \s-1CSS\s0 rule (not supported in internet explorer 6). .PP *\fIThis above is useful for simple forms. Complex forms with fieldsets and other extra features\fR *\fIwill require further styling of the \s-1HTML.\s0 The following rule is also \s-1HTML 5\s0 compatible.\fR .PP .Vb 5 \& form#id_of_your_form div div label, form#id_of_your_form div div input { \& float: left; \& display: inline\-block; \& width: 40% \& } /* make sure the parent element is sized appropriately. 700px is a good width */ .Ve .PP Going a little bit farther in using FormHandler rendering, you can render each of the fields individually, using 'render' or 'renderx': .PP .Vb 7 \& .Ve .PP If you don't want the wrappers, use a widget_wrapper of 'None'. .PP .Vb 1 \& has \*(Aq+widget_wrapper\*(Aq => ( default => \*(AqNone\*(Aq ); .Ve .PP Then you can provide the \s-1HTML\s0 in which the form elements are embedded: .PP .Vb 6 \&