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

Carl Franks fireartist at gmail.com
Wed Sep 27 17:28:29 CEST 2006


On 27/09/06, Adam Sjøgren <adsj at novozymes.com> wrote:
> Maybe I am using HTML::Widget in a stupid way with Catalyst, since
> this bit me, I'm not sure.

I don't think you're using it in a stupid way at all, there's just
different ways of using it.

The behaviour was changed because it was considered confusing
behaviour if an empty field caused an error, but the field was then
filled in with the default value. The error message wouldn't make much
sense.

> Maybe what I'm unconsciously implementing is different sets of
> "defaults for add" and "defaults for edit". Hm.

I'm not sure. I think your problem would be solved by being able to
mark specific elements as reverting to the old behaviour.

> I'm not sure what I think would be the best thing to do, I just needed
> to vent my problem.

No problem :)

There could be a widget-wide setting of
$w->retain_defaults( @element_names )
but then if you're adding elements on an ad-hoc basis (ajax
callbacks?), it'd probably be best to have the accessor at the element
level.

Something like...
 my $widget=HTML::Widget->new('mywidget');
 $widget->element('Submit', 'update')->value('Update')->retain_default(1);
 $widget->element('Submit', 'preview')->value('Preview')->retain_default(1);
... wouldn't that solve your problem?

Carl



More information about the Html-widget mailing list