On 7 November 2011 21:35, J. Bobby Lopez <j...@jbldata.com> wrote: > So I think I'm pretty close to what I'm heading for. Here's what I'm doing: > > my $field_EmailDL = $form_insert_data->get_field( { name => 'EmailDL'} ); > $field_EmailDL->options($emailDL_array); > > $emailDL_array contains the following: > > $VAR1 = [ > [ > 'label', > 'mylabel1', > 'value', > 'myvalue1' > ], > [ > 'label', > 'mylabel2', > 'value', > 'myvalue2' > ] > ]; > > Now I realize that setting ->options() will essentially overwrite the > value of the 'EmailDL'. That's fine, I fix that up later. > > What I'm trying to do now ( haven't found it in the docs ) is the way > to set one or more of the values in $emailDL_array to be selected. > > > The docs say: > "Its arguments must be an array-ref of items. Each item may be an > array ref of the form [ $value, $label ] or a hash-ref of the form { > value => $value, label => $label }. Each hash-ref may also have an > attributes key." > > Can "selected" be one of those attributes? How would I specify it? > > Based on the above, I've tried the following which doesn't work: > { value => $value, label => $label, attributes => {selected => 'selected'} } > > Should I be looking at another function altogether for setting 'selected' > items?
No, don't pass 'selected' to options. Either do this: $form->default_values( { EmailDL => \@default_values } ); or this: $field->default( \@default_values ); This will ensure the default values are selected when the form is first displayed, but not if the form's displayed again after an invalid submission. Carl _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu