use strict;
use warnings;
use Test::More;
use HTML::FormHandler::Test;
{
package MyApp::Form::Theme::Basic;
use Moose::Role;
sub build_do_form_wrapper {1}
sub build_form_tags {{ wrapper_tag => 'div' }}
sub build_update_subfields {{
all => { tags => { label_tag => 'span' } },
by_flag => { 'compound' => { do_wrapper => 1, do_label => 1,
tags => { wrapper_tag => 'span' }}},
}}
sub html_attributes {
my ( $self, $field, $type, $attr ) = @_;
$attr->{class} = ['frm', 'ele'] if $type eq 'element';
$attr->{class} = ['frm', 'lbl'] if $type eq 'label';
$attr->{class} = ['frm', 'wrp'] if $type eq 'wrapper';
return $attr;
}
}
{
package MyApp::Form;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
with 'MyApp::Form::Theme::Basic';
has_field 'my_comp' => ( type => 'Compound' );
has_field 'my_comp.one';
has_field 'my_comp.two';
has_field 'my_text' => ( type => 'Text' );
}
my $form = MyApp::Form->new;
my $rendered = $form->field('my_comp')->render;
my $expected =
'
My comp