[html-formfu] Populating $form_input with 'select' element options?

Carl Franks fireartist at gmail.com
Wed Nov 9 14:13:25 GMT 2011


On 8 November 2011 17:45, J. Bobby Lopez <jbl at jbldata.com> wrote:
> I went ahead and ripped out $query->Vars() wherever possible on your
> suggestion.  I have a fair handle now on populating the multi-select
> fields, using $form->get_field() to focus specifically on a single
> field.
>
> I'm using the following to populate the multi-select, which _is_ working:
>
>    $field->options($array_ref);
>
> Though, I still haven't been able to highlight individual options as selected:
>
>    $field->default($array_ref); # not working, but should be
>    $form->default_values({ EmailDL => [ 'myvalue1', 'myvalue2'] }); #
> not working, but should be
>
> I am however, able to set 'selected' on the overall <select> tag, which is odd:
>
>    $field->options($array_ref)->{attributes}->{selected} = 'selected';
>
> ..which generates this in HTML source:
> <select name="EmailDL" id="EmailDL" multiple="multiple" selected="selected">
>
> Although not what exactly what I want, it's helped my sanity somewhat  :)
>
> looked at 'select_multi_value.t' and 'select_multi_default_values.t'
> to make sure the syntax was right, but still no joy with setting
> 'selected' on individual options.
>
> Likely I'm just doing something incorrectly, but no idea what.
> Doesn't seem like it should be too complicated :\

Hi,
Unless you post your code, I can't really help you further!

$field->attributes() is just a dumb hashref, so will accept any
key/value you give it.

Carl



More information about the HTML-FormFu mailing list