There are a couple of ways you could do this. One would be to make your
own version of the wrapper, and add rendering of a comment tag.
You could also make 'after_element' a sub or a block:
package MyApp::Form::Test;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
has '+name' => ( default => 'test_form' );
has_block 'comment' => ( tag => 'span', content => 'This is a
comment from a block',
class => ['field_info' ] );
has_field 'foo' => ( tags => { after_element => '%comment' } );
has_field 'bar' => ( tags => { after_element => \&element_comment,
comment => 'my comment' } );
sub element_comment {
my $self = shift;
my $comment = $self->get_tag('comment');
return qq{<span class="field_info">$comment</span>};
}
Since you probably wouldn't want to create a block for every comment,
you'd probably want a custom block that pulls the comment from a tag (or
somewhere else). Making the 'after_element' tag a sub still means that
you need to set two tags. You can hide some of that by setting all of
your fields to have an 'after_element' sub with
'build_update_subfields', but I imagine you wouldn't want it for some
fields...
So there are a lot of options, but I think I'd go with a custom
Bootstrap wrapper, if it were me. It's probably a good idea in any case,
because there's always the risk of future changes if you're using the
stock wrapper.
Gerda