Form-Sensible
view release on metacpan or search on metacpan
lib/Form/Sensible/Renderer/HTML/RenderedForm.pm view on Meta::CPAN
}
sub complete {
my ($self, $action, $method, $manual_hints) = @_;
return join('', $self->start($action, $method), $self->messages, $self->fields($manual_hints), $self->end);
}
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 NAME
Form::Sensible::Renderer::HTML::RenderedForm - A rendered form handle for HTML
=head1 SYNOPSIS
use Form::Sensible::Renderer::HTML;
my $renderer = Form::Sensible::Renderer::HTML->new();
my $renderedform = $renderer->render($form);
print $renderedform->complete('/myform/submit', 'POST');
=head1 DESCRIPTION
The Form::Sensible::Renderer::HTML::RenderedForm class defines the result of
rendering a form as HTML. It is not generally created directly, but rather is created
by passing a form to the L<Form::Sensible::Renderer::HTML> C<render()> mathod.
=head1 ATTRIBUTES
=over 8
=item C<stash>
The stash used for the template processing. Additional information is added
to this stash automatically during field and form processing.
=item C<css_prefix>
This is applied to all html element CSS id's and class names. By default,
css_prefix is set to C<fs_>
=item C<render_hints>
Render hints provide information on how to render certain aspects of the form
or field. The usage depends upon the field type in question. The information
is passed through to the field-specific templates as 'render_hints' during
processing.
A hint that is specific to the HTML renderer is C<stash_vars>, this should be
a hash and will be passed to the templates as they are rendered.
{
stash_vars => {
user_prefs => $user_prefs
}
}
For example in the this case, C<$user_prefs> could be accessed in any
of the templates (form_start.tt, text.tt etc) as C<[% user_prefs %]>.
Another is C<field_wrapper> which should be the name of a template to act
as a wrapper for each individual field template. This can be useful if each
field has common HTML and only the actual field element changes. For example
in this case:
{
field_wrapper => 'field_wrapper_file'
}
A template called C<field_wrapper_file.tt> will be used. The C<field_wrapper>
hint overrides the built-in wrapper, so only the actual input field will be available
and you will need to provide any enclosing elements or labels. Note also that it
uses the standard L<Template|Template::Toolkit> C<WRAPPER> mechanism. Thus the field wrapper
template will be rendered, and the actual input elements will be available as
C<< [% content %] >> within your wrapper template. So your wrapper template
might end up looking like:
<tr class="form-row">
<td>[% field.display_name %]</td>
<td>[% content %]</td>
</tr>
For more information on render_hints, see L<Form::Sensible::Overview>.
Note that 'wrap_fields_with' has been deprecated and will be removed in a
future release.
=item C<status_messages>
An array ref containing the status messages to be displayed on the form.
=item C<error_messages>
An array ref containing the error messages to be displayed on the form.
=item C<form_template_prefix>
Non-field related template names are prefixed with this value. The three
templates used for each form are: C<start>, C<messages>, and C<end>,
The default value for C<form_template_prefix> is 'form', so by default
the form templates used are: C<form_start.tt,>
C<form_messages.tt,> and C<form_end.tt.>
=item C<subform_renderers> has
This contains the references to subform renderers. Subform rendering is
experimental and is still subject to changes. It's probably best to leave
this attribute alone for now.
=item C<form>
A reference to the L<form|Form::Sensible::Form> object that is being rendered.
=item C<template>
The template toolkit object to be used to process the templates. This is
normally set up prior to rendering and should only be changed if you know
what you are doing. In other words, unless you've read the source, it's
a good idea to leave this alone.
( run in 1.533 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )