[Html-widget] Default values of Submit-elements after form-submission

Adam Sjøgren adsj at novozymes.com
Wed Sep 27 14:39:04 CEST 2006


I'm looking at the effects of upgrading an app from using HTML::Widget
1.07 to 1.09, and I've bumped into this in the Changelog:

 - After form submission, $result->as_xml() no longer uses an elements' 
   default value if that field wasn't submitted.

in relation to Submit-elements.

The immediate effect of the change is that the "Save"-buttons on my
editing pages changed to "Submit query".

Here is the content of a minimal example (attached), hopefully
illustrating the problem:

 my $widget=HTML::Widget->new('mywidget');
 $widget->element('Submit', 'update')->value('Update');
 $widget->element('Submit', 'preview')->value('Preview');

 my $q=MyParam->new({ update=>'Update' });
 my $result=$widget->process($q);

 print $result->as_xml;

The form has two buttons, "Update" and "Preview". The $q simulates that
the "Update"-button was clicked.

The result, if displayed, looks like this:

 .--------. .--------------.
 | Update | | Submit query |
 `--------' `--------------'

Which looks odd.

In 1.07 it looks fine: "Update" "Preview".

I guess one could argue that this is an artefact of HTML's abuse of
the value attribute on input-elements of type submit for the text
displayed on the button. Nevertheless, it used to work the way I would
expect and now it doesn't.

Should I just bite the sour apple and keep a list of my Submit-buttons
with values and prefill my $q's with them, or what less cumbersome
solution have I overlooked?

  Best regards,


                                                          Adam Sjøgren
                                                    adsj at novozymes.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit-value.pl
Type: text/x-perl
Size: 513 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/html-widget/attachments/20060927/ff324c6f/attachment.pl 

More information about the Html-widget mailing list