This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
use JSON::XS; | |
my $json = JSON::XS->new->utf8->pretty; | |
app->secret('as time goes by'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Test::More; | |
use lib 't/lib'; | |
# Simulate submitting a form when creating/inserting a new row | |
# Where the form has a (optional) Select field without a default. | |
# <select name=format> | |
# <option></option> | |
# <option value=1>Paperback</option> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub edit :Local :MyAction('Admin') { | |
my ($self, $c, $action_id) = @_; | |
return $c->response->redirect('/admin/action/list') | |
if $c->req->param('list'); | |
my $db = $c->model('Item::Action'); | |
if ($action_id) { | |
my $action = $db->find($action_id) | |
or return $self->respond_404($c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Data::Dumper; | |
warn Dumper $c->request->parameters; | |
return if !$form->process( | |
item_id => $action_id, | |
schema => $c->model('Item')->schema, | |
params => $c->request->parameters, | |
); | |
warn Dumper $form->values; | |
gets me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
re: App that worked fine under Catalyst 5.7 after upgrading to 5.8 | |
M:C:Product.pm | |
use strict; use warnings; | |
package My::Controller::Product; | |
use parent 'My::Controller::_Base'; | |
With M:C:_Base.pm as: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package My::Types; | |
use strict; | |
use warnings; | |
use MooseX::Types -declare => [qw<MyPosNum>]; | |
use HTML::FormHandler::Types; | |
subtype MyPosNum, | |
as 'PositiveNum', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in HTML::FormHandler::Types | |
subtype PositiveNum, | |
as Num, | |
where { $_ >= 0 }, | |
message { "Must be a positive number" }; | |
# I would like to change the 'message'. | |
# Is there a way I can sub-class a Moose class, | |
# and change the 'message' bit of the PositiveNum subtype? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML::FormHandler::Types; | |
subtype PositiveNum, | |
as Num, | |
where { $_ >= 0 }, | |
message { "Must be a positive number" }; | |
type { 'not_positive_num' } | |
subtype PositiveInt, | |
as Int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
### THIS WORKS | |
package MyApp::Controller::Redux; | |
use strict; | |
use warnings; | |
use parent 'Catalyst::Controller'; | |
use HTML::FormHandler::Model::DBIC; |