[html-formfu] content_xml => \&coderef
Ben Vinnerd
ben-formfu at vinnerd.com
Thu Feb 24 12:58:12 GMT 2011
Hi,
I'm looking for a way to set some content in a Block element, easy if
the content is static, but i'd like to be able to pass a code ref
instead that returns a text string, based on the type of user
currently logged in (some field in a DBIx::Class row) . e.g. <below>
Can this be done?
Ben
e.g.:
## Code
package Myapp::FormFu::Content;
sub return_string
{
my $self = shift;
my $c = $self->form->stash->{context};
if ($c->user->type eq 'A') {
return 'Hello, user type A';
}
elsif ($c->user->type eq 'B') {
return 'Hello, user type B';
}
else {
return 'Unknown user';
}
}
# Form config
{
type => 'Block',
content_xml => '+Myapp::FormFu::Content',
}
More information about the HTML-FormFu
mailing list