Skip Menu |

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 90813
Status: resolved
Priority: 0/
Queue: HTML-FormFu

People
Owner: Nobody in particular
Requestors: ian.baber [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: HTML::FormFu::Element::Repeatable - duplicating field value when changing from ->repeat(1) to ->repeat(2)
Date: Mon, 25 Nov 2013 14:29:33 -0800
To: bug-HTML-FormFu [...] rt.cpan.org
From: Ian Baber <ian.baber [...] gmail.com>
I'm building a form where the user needs to enter a section one or more times, so I'm using Element::Repeatable. There is a submit button to "add another section", causing the app to modify the form adding a section, and redisplay it with all entered values. I'm not using increment_field_names, the goal here is for the application to get several parameters that are arrays of the same length, where each represents one field in the repeating section ( e.g. email="user@host","user@otherhost" type="work","personal" ) When there are 2 or more sections already in the form, this works as expected, and all fields in the newly added repeating section are blank. However, if the repeating section is only exists once in the form, and the "add another section" button is clicked, whatever values were populated or entered in the first section are copied to the second section. It looks like FormFu incorrectly handles the param value when it is a scalar (only one value submitted by the client) and sets that value on multiple elements. Adding extra hidden elements to the form with the same name as the repeated elements is an effective workaround, causing every param to always be read as an array of values with an extra empty string at the end.
I've added a new Filter and some docs to describe dealing with this issue - hope it suitable addresses the problem. https://github.com/fireartist/HTML-FormFu/commit/60d8e3853bb0ec00856a73bcb2efd6826b9a4d51 It'll be included in the next cpan release.