[Html-widget] opinions of removing implicit fieldset / breaking back-compat

Carl Franks fireartist at gmail.com
Wed Nov 8 13:57:17 GMT 2006


On 08/11/06, Andreas Marienborg <omega at palle.net> wrote:
> HTML::Widget really should produce valid XML/XHTML, as the method is
> named as_xml

While I don't disagree, my question was whether it's acceptable to
force users to take an extra step to ensure that.

I can see a possible alternative...

The original behaviour was: you add elements to a widget, this produced...
<form>
  <fieldset>
    <input>
    <input>
  </fieldset>
</form>
The fieldset could be set to a different tag type, using
$w->subcontainer( 'p' ) to create a paragraph, for example.

To support new Fieldset and Block elements, we made the decision that
if a Block/Fieldset was the first element added to the widget, the
implicit fieldset wasn't added because you were going to add the
elements to the block you created yourself, and you might want to nest
fieldsets while you were at it.

Instead, we could go back to always adding the implicit fieldset,
regardless of what type of element is added to the widget first.
The effect of this will be - for people adding an explicit fieldset,
then adding elements to that fieldset - there would be an extra
fieldset created.

$fs = $w->element( 'Fieldset' );
$fs->element( Textfield => 'foo' );
#
<form>
  <fieldset>
    <fieldset>
      <input>
    </fieldset>
  </fieldset>
</form>
It would probably be trivial to fix this by adding an option for
$w->no_subcontainer(1)
to get rid of the implicit subcontainer.
This would leave much less mess in the internals than the current
checks for 'implicit_subcontainer' do.

Is this a better compromise?
It will have no effect on code written before the Block/Fieldset were
introduced in August, and the fix required - a new method call - is
much simpler than my previously suggested change of adding all
elements to a fieldset instead of the widget.

The no_subcontainer() could also be used for people proud to be using
HTML4, Ash ;P

Carl



More information about the Html-widget mailing list