SyForm::Class - TODO
version 0.009
package MyApp::MyForm; use SyForm::Class; field_roles qw( MyApp::SyForm::FieldRole ); # given to all fields on creation field_args custom_value => 2, other_custom => 2; values_roles qw( MyApp::SyForm::ValuesRole ); # Results roles are given via Values role # and View roles are given via Results role # ViewField roles are given via Field role # Or directly set your own classes, which is not recommended! # use roles for this, please. # values_class qw( MyApp::SyForm::Values ); # field_class qw( MyApp::SyForm::Field ); field username => ( required => 1, label => 'Your name', ); field age => ( decimal => 1, label => 'Your age', ); field unchecked => ( label => 'Unchecked', ); has outside_value => ( is => 'ro', required => 1, ); field dynamic => sub { my ( $self ) = @_; # SyForm::Class object if ($self->outside_value > 5) { return label => 'That...' required => 1; } return label => 'Or this'; };
Usage:
my $thing = MyApp::MyForm->new; my $syform = $thing->syform; # if you need to my $view = $thing->process(%params); if ($view->success) { # ... }
SyForm::Class is a simple way to store the field definitions and other form variables via a package level configuration. It is not actually making your class a SyForm class, it is just holding the data and will supply a SyForm on syform and can directly process args via process.
IRC
Join #sycontent on irc.perl.org. Highlight Getty for fast reaction :).
Repository
http://github.com/SyContent/SyForm Pull request and additional contributors are welcome
Issue Tracker
http://github.com/SyContent/SyForm/issues
Torsten Raudssus <torsten@raudss.us>
This software is copyright (c) 2014 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install SyForm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SyForm
CPAN shell
perl -MCPAN -e shell install SyForm
For more information on module installation, please visit the detailed CPAN module installation guide.