-
-
04 Aug 2016 10:43:59 UTC
- Distribution: Dancer2-Plugin-TemplateFlute
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues
- Testers (502 / 0 / 0)
- Kwalitee
Bus factor: 2- 64.58% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (21.98KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Evan Brown (evan@bottlenose-wine.com)
- Dependencies
- Carp
- Dancer2
- Dancer2::Plugin
- Dancer2::Template::TemplateFlute
- Hash::MultiValue
- Moo
- Type::Tiny
- namespace::clean
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Dancer2::Plugin::TemplateFlute::Form - form object for Template::Flute
ATTRIBUTES
name
The name of the form.
Defaults to 'main',
action
The form action.
errors
Errors stored in a Hash::MultiValue object.
Get form errors:
$errors = $form->errors;
- writer: set_errors
-
Set form errors (this will overwrite all existing errors):
$form->set_errors( username => 'Minimum 8 characters', username => 'Must contain at least one number', email => 'Invalid email address', );
- clearer: clear_errors
NOTE: Avoid using
$form->errors->add()
or$form->errors->set()
since doing that means that "valid" does not automatically get set to0
. Instead use one of "add_error" or "set_error" methods.fields
Get form fields:
$fields = $form->fields;
log_cb
A code reference that can be used to log things. Signature must be like:
$log_cb->( $level, $message );
Logging is via "log" method.
pristine
Determines whether a form is pristine or not.
This can be used to fill the form with default values and suppress display of errors.
A form is pristine until it receives form field input from the request or out of the session.
session
A session object. Must have methods
read
andwrite
.Required.
valid
Determine whether form values are valid:
$form->valid();
Return values are 1 (valid), 0 (invalid) or
undef
(unknown).The form status automatically changes to "invalid" when "errors" is set or either "add_errors" or "set_errors" are called.
values
Get form values as hash reference:
$values = $form->values;
- writer: fill
-
Fill form values:
$form->fill({username => 'racke', email => 'racke@linuxia.de'});
- clearer: clear_values
METHODS
add_error
Add an error:
$form->add_error( $key, $value [, $value ... ]);
errors_hashed
Returns form errors as array reference filled with hash references for each error.
For example these "errors":
{ username => 'Minimum 8 characters', email => 'Invalid email address' }
will be returned as:
[ { name => 'username', value => 'Minimum 8 characters' }, { name => 'email', value => 'Invalid email address' }, ]
from_session
Loads form data from session key
form
. Returns 1 if session contains data for this form, 0 otherwise.log $level, @message
Log message via "log_cb".
reset
Reset form information (fields, errors, values, valid) and updates session accordingly.
set_error
Set a specific error:
$form->set_error( $key, $value [, $value ... ]);
to_session
Saves form name, form fields, form values and form errors into session key
form
.AUTHORS
Original Dancer plugin by:
Stefan Hornburg (Racke),
<racke at linuxia.de>
Initial port to Dancer2 by:
Evan Brown (evanernest),
<evan at bottlenose-wine.com>
Rehacking to Dancer2's plugin2 and general rework:
Peter Mottram (SysPete),
<peter at sysnix.com>
BUGS
Please report any bugs or feature requests via GitHub issues: https://github.com/interchange/Dancer2-Plugin-TemplateFlute/issues.
We will be notified, and then you'll automatically be notified of progress on your bug as we make changes.
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2011-2016 Stefan Hornburg (Racke).
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Module Install Instructions
To install Dancer2::Plugin::TemplateFlute, copy and paste the appropriate command in to your terminal.
cpanm Dancer2::Plugin::TemplateFlute
perl -MCPAN -e shell install Dancer2::Plugin::TemplateFlute
For more information on module installation, please visit the detailed CPAN module installation guide.