Howdy Robed Ones!

I wanted to know if it is possible to pass a DBIx::Class ResultSet into HTML::FormHandler such that all instances are displayed. Presumably these would use the HFH Repeatable functionality.

To put this as a more concrete example, assume a person's phone (work, home ...) with the standard US fields (areacode, number ...). A single phone number row could be coded as such and it works fabulous (I happen to be working with Catalyst, so the code is of that nature):

my $formPhone = MyApp::Form::Phone->new; $formPhone->process(item => $c->model('MyDb')->find(1), params => $c->request->params); $c->stash->{formPhone} = $formPhone;
Corresponding form code:
use HTML::FormHandler::Moose; extends 'HTML::FormHandler'; with 'HTML::FormHandler::Render::Table'; has_field 'area_code' => (type => 'Text', label => 'Area Code', +required => 1, css_class=>'required_field'); has_field 'number' => (type => 'Text', label => 'Home Phone', re +quired => 1, css_class=>'required_field'); __PACKAGE__->meta->make_immutable; 1;
When a ResultSet is passed in:
my $formPhone = MyApp::Form::Phone->new; $formPhone->process(item => $c->model('MyDb')->search(...)->all, params => $c->request->params); $c->stash->{formPhone} = $formPhone;
Corresponding (approximation) repeatable form code :
use HTML::FormHandler::Moose; extends 'HTML::FormHandler'; with 'HTML::FormHandler::Render::Table'; has_field 'phone' => ( type => 'Repeatable' ); has_field 'phone.id' => ( type => 'PrimaryKey' ); has_field 'phone.area_code' => (type => 'Text', label => 'Area Code', +required => 1, css_class=>'required_field'); has_field 'phone.number' => (type => 'Text', label => 'Home Phone', re +quired => 1, css_class=>'required_field'); __PACKAGE__->meta->make_immutable; 1;
the code blows up with:
invalid attribute 'HASH(Ox...)' passed to setup_form at ... FormHandler.pm line 853

What is the right way to do this? (HFH v. 0.30003)

In reply to HTML::FormHandler, Repeatables and DBIC ResultSet by nybble_1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.