[html-formfu] Possible bug - Submit element when forms have errors

onken at houseofdesign.de onken at houseofdesign.de
Wed Feb 18 10:34:41 GMT 2009


On Wed, 18 Feb 2009 09:38:58 +0000, Carl Franks <fireartist at gmail.com>
wrote:
> 2009/2/18  <onken at houseofdesign.de>:
>>
>> On Tue, 17 Feb 2009 15:30:36 -0800, Greg Coates <greg at coatesoft.com>
>> wrote:
>>> I think I might have found a bug.  I have HTML::FormFu version 0.03007
>>> installed.  Here's what's happening.
>>>
>>> I created a form that ends with the following 3 submit buttons:
>>> ---
>>>    - type: Submit
>>>      name: submit
>>>      value: Save for Later
>>>    - type: Submit
>>>      name: submit
>>>      value: Finish
>>>    - type: Submit
>>>      name: submit
>>>      value: Cancel
>>>
>>> These display as expected.  However, if the form is submitted, contains
>>> errors, and then is re-displayed, the buttons all contain the same
text.
>>>   Here's the HTML that is generated:
>>>
>>> <input name="submit" type="submit" value="Save for Later" />
>>> <input name="submit" type="submit" value="Save for Later" />
>>> <input name="submit" type="submit" value="Save for Later" />
>>>
>>> All the values get set to the same value for some reason.
>>>
>>> Greg Coates
>>>
>>
>> I think this is not a bug. How should FormFu distinguish between
>> those fields if they have the same name?
> 
> You're correct that it'd be better for the different submit buttons to
> have different names.
> However, there may be an argument that a button's rendered value
> shouldn't be affected by any submitted value.
> 
> Greg, if your form were changed to something like this:
> ---
>  - type: Submit
>    name: save
>    value: Save for Later
>  - type: Submit
>    name: finish
>    value: Finish
>  - type: Submit
>    name: cancel
>    value: Cancel
> 
> Then your code would change from checking the submitted value, to
> checking which name was sent:
>     if ( $form->param('save') ) { }
>     elsif ( $form->param('finish') ) { }
>     # etc...
> 
> This works because browsers only submit a name=value pair for the
> submit value that's clicked, and not for any other that wasn't
> clicked.
> 
> So, in summary, this may be a bug - but before saying I'll accept a
> patch, I'd prefer to give a time for anyone to speak up if they think
> 'fixing' it could have unfortunate consequences.
> 
> Carl
> 

If you stick to Element::Button you cannot break anything else, can you?
I think it's woth fixing because you would expect this behaviour.
I thought "retain_default" would take care of this problem?!


moritz



More information about the HTML-FormFu mailing list