Hello,

Using HTML::FormFu, I'm trying to understand the data-structure required to populate a form with 'select' element values (options).

When I dump (Data::Dumper) the FormFu object, I see that the object structure looks similar to the following:

'name' => 'EmailDL', '_options' => [ { 'label_attributes' => {}, 'value' => 'm', 'container_attributes' => {}, 'label' => 'Male', 'attributes' => {} }, { 'label_attributes' => {}, 'value' => 'f', 'container_attributes' => {}, 'label' => 'Female', 'attributes' => {} } ],

Seeing this, I figured that the way to structure $form_input (being that $form_input = \%cgivars) would be something like the following:

'Firstname' => 'Faisal', 'EmailDL' => [ { 'value' => 'myvalue', 'label' => 'mylabel' } ],

However this doesn't seem to work. I've found that structuring $form_input correctly, and then issuing a $fu->default_values($form_input) to be simple and effective, except in this instance when I'm trying to include the select/options sub-structure.

So the question is: How should I structure 'EmailDL' above to correctly populate 'select' options when doing $fu->default_values($form_input) or $fu->process($form_input) ?

Any guidance on this would be appreciated, thanks!
-Bobby


In reply to Populating $form_input with 'select' element options? (HTML::FormFu) by jbl_bomin

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.