NAME
Form::Sensible::Renderer::HTML::RenderedForm - A rendered form handle for HTML
SYNOPSIS
use Form::Sensible::Renderer::HTML;
my $renderer = Form::Sensible::Renderer::HTML->new();
my $renderedform = $renderer->render($form);
print $renderedform->complete('/myform/submit', 'POST');
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 Form::Sensible::Renderer::HTML render()
mathod.
ATTRIBUTES
stash
-
The stash used for the template processing. Additional information is added to this stash automatically during field and form processing.
css_prefix
-
This is applied to all html element CSS id's and class names. By default, css_prefix is set to
fs_
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 feild-specific templates as 'render_hints' during processing.
status_messages
-
An array ref containing the status messages to be displayed on the form.
error_messages
-
An array ref containing the error messages to be displayed on the form.
form_template_prefix
-
Non-field related template names are prefixed with this value. The three templates used for each form are:
start,
messages,
andend.
The default value forform_template_prefix
is 'form', so by default the form templates used are:form_start.tt,
form_messages.tt,
andform_end.tt.
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.
form
-
A reference to the form object that is being rendered.
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.
template_fallback_order
-
An array ref containing the order to seek for overriding templates for all elements of form rendering. By default, a subdirectory named after the
$form->name
is searched first, then the root template directory is searched.
METHODS
add_status_message($message)
-
Adds $message to the status messages to be displayed.
add_error_message($fieldname, $message)
-
Adds the error message provided in
$message
to the list of error messages to be displayed. The error message is associated with the$fieldname
given. add_errors_from_validator_result($validator_result)
-
Inspects $validator_result and adds any messages found to the list of errors to be displayed on the form.
start($action, $method)
-
This renders the start of the form and sets it to be submitted to the url provided in
$action
.$action
is placed directly in to theaction
attribute of theform
element. Returns the rendered HTML as a string. messages()
-
This renders the messages portion of the form. Often (and by default) this is displayed before the form fields. Returns the rendered messages html as a string.
render_field($fieldname, $render_hints)
-
Renders the field matching
$fieldname
and returns the rendered HTML for the field. If the$render_hints
hashref is provided, it will be merged into any previously set render hints for the field. When a key conflict occurs the passed$render_hints
will override any existing configuration. fields()
-
A shortcut routine that renders all the fields in the form. Returns all of the fields rendered as a single string.
end
sub-
Renders the end of the form. Returns the rendered html as a string.
fieldnames()
-
Returns an array containing the fieldnames in the form (in their render order)
complete($action, $method)
-
Renders the entire form and returns the rendered results. Calling
<$form-
complete($action, $method) >> routine is functionally equivalent to calling:$form->start($action, $method) . $form->messages() . $form->fields() . $form->end();
AUTHOR
Jay Kuri - <jayk@cpan.org>
SPONSORED BY
Ionzero LLC. http://ionzero.com/
SEE ALSO
LICENSE
Copyright 2009 by Jay Kuri <jayk@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.