An open API service indexing awesome lists of open source software.

https://github.com/throughnothing/dancer-plugin-datafu

Dancer HTML Form and Grid/Table engine with Input Validation
https://github.com/throughnothing/dancer-plugin-datafu

Last synced: 10 months ago
JSON representation

Dancer HTML Form and Grid/Table engine with Input Validation

Awesome Lists containing this project

README

          

Dancer-Plugin-DataFu - Dancer HTML Form and Grid/Table engine with Input Validation

use Dancer qw/:syntax/;
use Dancer::Plugin::DataFu;

# form rendering and validation

get 'login' => sub {
return form->render('form_name', '/action', 'profile.field', 'profile.field');
# return form->render('login', '/submit_login', 'user.login', 'user.password');
};

post 'login' => sub {
my $input = form;
return redirect '/dashboard' if $input->validate('user.login', 'user.password');
redirect '/login';
};

# grid rendering

# Important Note! The order arguments are received by the render function
# has now changed. Please examine.

get '/user_list' => sub {
return grid->render('table_name', 'profile_name', $dataset);
# $dataset is an array of hashes
};

# grid rendering with Dancer::Plugin::DBIC

get '/user_list' => sub {
my $rs = schema->resultset('Foo');
$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
return grid->render('table_name', 'profile_name', [$rs->all]);
};

To install this module using code from CPAN,
run the following commands

cpan Dancer::Plugin::DataFu

or

perl Makefile.PL
make
make test
make install

To install this module using code from the git repository,
run the following commands (Dist::Zilla required):

dzil build
cd Dancer-Plugin-DataFu-#.##
cpan .

REPOSITORY

http://github.com/alnewkirk/Dancer-Plugin-DataFu/

COPYRIGHT AND LICENCE

Copyright (C) 2010 Al Newkirk

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.