Skip to content

Commit

Permalink
Initial throw up
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Nov 1, 2009
1 parent 4420123 commit 4081337
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dist.ini
@@ -1,4 +1,4 @@
name =
name = Catalyst-Plugin-Spark-Form
author = Kent Fredric <kentnl@cpan.org>
license = Perl_5
copyright_holder = Kent Fredric
Expand All @@ -7,9 +7,9 @@ copyright_holder = Kent Fredric
major = 0
minor = 1
year = 2009
month = 10
day = 26
hour = 12
month = 11
day = 02
hour = 07
time_zone = Pacific/Auckland

[AllFiles]
Expand Down Expand Up @@ -44,5 +44,6 @@ time_zone = Pacific/Auckland
[UploadToCPAN]

[Prereq]

Moose = 0.92
namespace::autoclean = 0.09

66 changes: 66 additions & 0 deletions lib/Catalyst/Plugin/Spark/Form.pm
@@ -0,0 +1,66 @@
package Catalyst::Plugin::Spark::Form;

# A simple plugin to make forms accessible quickly off the CTX.

# $Id:$
use strict;
use warnings;

use Moose;
use namespace::autoclean;

=head1 SYNOPSIS
use Catalyst qw/ Spark::Form /;
...
sub action {
my ( $self, $ctx, @rest ) = @_;
$ctx->form('bar') # loads My::Project::Form::Bar or My::Project::F::Bar
}
=cut

=head1 METHODS
=head2 form
$ctx->form( $formname )
=cut

sub form {
my ( $ctx, $name, @args ) = @_;

if ($name) {
my @result = $c->_comp_search_prefixes( $name, qw/Form F/ );
if ( ref $name ) {
return map { $c->_filter_component( $_, @args ) } @result;
}
return $c->_filter_component( $result[0], @args );
}

return $c->component( $c->action->class );

}

=head1 CREDITS
Code thrown together by James Laver L<http://jameslaver.com>.
Code stolen from $c->controller.
=cut

=head1 DISCLAIMER
The code mightn't work, but its not my fault if it doesn't. Will gladly accept patches.
=cut

1;


0 comments on commit 4081337

Please sign in to comment.