[Html-widget] Seemingly incorrect fieldset behavior

Michael Alan Dorman mdorman at tendentious.org
Mon Oct 2 20:09:43 CEST 2006


Hi, all.

I have the following script:

   #!/usr/bin/perl

   use strict;
   use warnings;
   use HTML::Widget;

   my $widget = HTML::Widget->new ('widget')->legend ('Widget');
   $widget->element (Textfield => 'a')->label ('A');
   my $fieldset = $widget->element (Fieldset => 'fieldset');
   $fieldset->legend ('Fieldset');
   $fieldset->element (Textfield => 'b')->label ('B');
   $widget->element (Textfield => 'c')->label ('C');
   my $result = $widget->process;
   print $result;

This produces the following output (indented by hand):

   <form id="widget" method="post">
     <fieldset>
       <legend id="widget_legend">Widget</legend>
       <label for="widget_a" id="widget_a_label">A<input 
class="textfield" id="widget_a" name="a" type="text" />
       </label>
       <label for="widget_c" id="widget_c_label">C<input 
class="textfield" id="widget_c" name="c" type="text" />
       </label>
     </fieldset>
     <fieldset>
       <legend id="widget_legend">Fieldset</legend>
       <label for="widget_b" id="widget_b_label">B<input 
class="textfield" id="widget_b" name="b" type="text" />
       </label>
     </fieldset>
   </form>

I don't understand why the fieldset containing textfield B has been 
relocated to be after the top-level fieldset?  I checked the HTML 
standard, and nested fieldsets certainly seem to be legal there, so 
there would seem to be no need for this behavior in order to satisfy 
some external requirement---so is this a bug or a feature?

Mike.



More information about the Html-widget mailing list