[Html-widget] Creating separate fieldsets in a form

Bogdan Lucaciu bogdan at wiz.ro
Tue Aug 29 11:16:16 CEST 2006


On Tue, 2006-08-29 at 08:39 +0100, Michael Gray wrote:
> On Mon, 28 Aug 2006, A. Pagaltzis wrote:
> 
> > FWIW, Michael Gray is currently working on a large patch to
> > refactor the rather… unfortunate set of design choices which led
> > to this limitation. One of the next versions of H::W will support
> > nesting fieldsets arbitrarily.
> 
> Yup, sorry I meant to reply to the original poster but ran out of time.  
> The SVN version at http://oook.de/svn/trunk/HTML-Widget has this 
> support, see t/element_block.t and t/09nested_embed.t.

I'm using trunk with the new updates, they seem to work very nice (for
my needs anyway :) ).

I noticed these (not very important) problems though:

1.
the fact that an id is always generated, although I rarely need an id,
so the DOM namespace gets severly poluted with useless ids:

(real life example)
<label for="add_category_main_fieldset_attributes_fieldset_1_freeform_1"
id="add_category_main_fieldset_attributes_fieldset_1_freeform_1_label">

I know this is mostly a container problem, but now with the nested
fieldsets the ids can get quite long and redundant. 

2. Most forms look like this: (a main fieldset, containing several small
fieldsets with inputs and a final submit button)
<form>
    <fieldset>
    <legend>Sign Up</legend>
        <fieldset> 
            <legend>Personal data</legend>
            <input>
            <input>
        </fieldset>

        <fieldset>
            <legend>Authentication details</legend>
            <input>
            <input>
        </fieldset>

        <input type="submit">

   </fieldset>
</form>


Whenever I add a fieldset element in the widget, it is rendered directly
as <form> children. But if I add a non-fieldset element, a fieldset is
automatically created to hold it (default behaviour in the earlier
version) , but the other fieldsets don't get embedded in this automatic
main fieldset, but go right under it. So the result is something like:

<form>
    <fieldset> (the autogenerated one)
        <input type=submit>
    </fieldset>
    <fieldset> (personal data)
    ...
    </fieldset> 
    <fieldset> (authentication)
    ...
    </fieldset>
</form>

This is very simply corrected if I add the main fieldset manually, and
put the other fieldsets and the submit button in it.

the obvious bugfix is to render the elements in the order they were
added (don't put the submit button on top if it was added after those
fieldsets)


Besides that, a DWIM behaviour (for me anyway) would be these elements
should be syblings in the DOM Tree:
$w->element('Fieldset');
$w->element('Fieldset');
$w->element('Submit');


I don't know if it was clear enough, I can write a test if needed.
Thanks!


-- 
Bogdan Lucaciu <bogdan at wiz.ro>




More information about the Html-widget mailing list