NAME
Form::Tiny::Plugin - base class for Form::Tiny plugins
SYNOPSIS
package Form::Tiny::Plugin::MyPlugin;
use parent 'Form::Tiny::Plugin';
sub plugin
{
my ($self, $caller, $context) = @_;
return {
subs => {
subname => sub { ... },
},
roles => ['My::Role', ...],
meta_roles => ['My::Meta::Role', ...],
};
}
DESCRIPTION
If you wish to extend Form::Tiny, plugins system is your best bet. It allows you to specify:
subs which will be added to the namespace
roles which will be composed to the package
meta roles which will be composed to the meta object
You may specify all, any, or none of those in the resulting hashref of the plugin method. It will be called in class context:
Form::Tiny::Plugin::MyPlugin->($caller, $context);
Where:
$callerwill be the package that calleduse Form::Tinywith your plugin$contextwill be a scalar reference to the current field context of the formThe context may be referencing either Form::Tiny::FieldDefinition or Form::Tiny::FieldDefinitionBuilder (depending on whether the field was dynamic).
To use your plugin in a form, Form::Tiny must be imported like this:
use Form::Tiny plugins => [qw(MyPlugin +Full::Namespace::Plugin)];
Prepending the name with a plus sign will stop Form::Tiny from prepending the given name with Form::Tiny::Plugin::.
Your plugin package must inherit from Form::Tiny::Plugin and must reintroduce the plugin method (without calling SUPER::plugin).