[dancer-users] Retrieving params of fields with multiple values
Andrew Beverley
andy at andybev.com
Thu Aug 21 10:55:01 BST 2014
Hi guys,
I may be missing something here, so I wanted to run this by you:
When a form is submitted that has multiple fields with the same name
(such as several checkboxes), the values of that field are all returned
in an array ref.
However, if the same form is submitted, but only one value is returned
(eg. only one checkbox has been ticked) then a scalar is returned. If no
checkboxes are ticked, then undef is returned.
This makes it difficult to process a form with several checkboxes, as
the return value from param('checkbox') can be an array ref, scalar or
undef, depending how many checkboxes are ticked.
At the moment, I'm testing for each of those 3 conditions. Is there a
better way?
It would be useful if param() could be called in array context, in which
case it would return 0, 1 or several items, depending on which ones were
checked.
Thanks,
Andy
More information about the dancer-users
mailing list