logo       

Re: Seemingly incorrect fieldset behavior: msg#00009

Subject: Re: Seemingly incorrect fieldset behavior
On Oct 2 2006, Michael Alan Dorman wrote:

>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;
>
> ...
>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?

It's a feature - or possibly a bug, but one that can be avoided by 
following the now-recommended usage. When you add the first Textfield, H::W 
generates an implicit fieldset and puts the Textfield in it. When you add a 
fieldset to the widget, it appends it after the implicit fieldset.

What is recommended is that you add your own top-level fieldset explicitly, 
and add your Textfield and nested fieldset to that:

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

Should do what you are expecting.

-- 
Michael


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe