[html-formfu] get_element problem

Dermot paikkos at googlemail.com
Fri Oct 31 13:23:20 GMT 2008


2008/10/31 Carl Franks <fireartist at gmail.com>:
> 2008/10/31 Dermot <paikkos at googlemail.com>:
>> Hi,

>> Is there something wrong with the snippet/yml file below?
>
> several things :)
>
>> ...
>>  else {
>>    my @types = keys %fileTypes;
>>    $c->log->debug("Types ",join ', ', @types);
>>    my $select = $form->get_elements( {name => 'filetypes'});
>>    $c->log->debug("Select is ", $select);
>>    $select->options(\@types);
>>    $c->stash->{template} = 'files/foo.tt2';
>>  }
>
> You're using auto_fieldset - so get_elements() will only return the
> top-level fieldset - nothing else.

That twice you've mention auto_fields in replies to me.

> You're calling get_elements - note the "s" on the end - that would
> return an arrayref, which isn't what you want.

I think that crept in while I attempting to trying both methods.

> If you're wanting a field - which you do - then forget all about
> get_element(s) / get_all_element(s) - just use either get_field() or
> get_fields()
>
> get_field() returns a single field object
> get_fields() returns an arrayref of field objects

Point taken. And it works:

<div class="select label">
<label>The file type</label>
<select name="filetypes" title="The file&#39;s type">
</select>
</div>

Thanx for the speedy reply Carl.
Dp.



More information about the HTML-FormFu mailing list