I need to create array of checkboxes in my form.
As I understand I have to use (type => 'Repeatable') field.
I've created fields in the form class:
has_field 'userroles' => ( type => 'Repeatable');
has_field 'userroles.idx' => ( type => 'Checkbox');
I've passed role ids in constructor:
my $form = MyApp::Form::adduser->new(
ml_labels => $c->stash->{labels},
userlang => $c->stash->{userlang},
langs_available => [map{+{value => $_->id, label => $_->id}}@all_langs],
userroles => [
{ idx => 5 },
{ idx => 6 },
{ idx => 7 }
]
);
and try to render this fields in template
<div style="float:left">
[% form.field('userroles').render %]
</div>
but I got only:
<div style="float:left">
<div class="hfh-repinst">
<div>
<label for="userroles.0.idx">Idx</label>
<label class="checkbox" for="userroles.0.idx"><input type="checkbox" name="userroles.0.idx" id="userroles.0.idx" value="1" />
</label>
</div>
What should I do to get three checkboxes with names '5','6','7'? I can't find the answer in the documentation to H::FH. Even on the page that seems to contain example