[Melbourne-pm] Resetting a field in WWW::Mechanize?

Nathan Bailey web at polynate.net
Fri Mar 22 04:01:41 PDT 2019

Hi all,
 I am using WWW::Mechanize with submit_form() to post a form.

The form has multiple values for the same field (ie. date = '1/1/12', date
= '1/2/12', date = '1/3/12').

I am trying to work out how to remove the values (I want to send a scalar,
not an array). I can reset them to blank, but then I end up submitting a
array of blanks ('', '', '') rather than a scalar.

I've tried:
1. Using various invocations of $form->field() (eg. field(date => '1/1/12)
and field(date => [ '1/1/12'])
2. Getting the form using $mech->current_form() and trying to play with the
inputs ($form->inputs)
3. Using $form->param() (whose POD says it will reset the field if an
arrayref is supplied)
(It seems that WWW::Mechanize's form methods are all wrappers around
HTML::Form, so this is probably an HTML::Form problem really)

I can "reach inside" the module and empty inputs:
       $form->{inputs} = [];
but this is ugly and resets all the fields, I'd prefer to just reset the
date field.

I feel like I'm missing something obvious, but this isn't an easy thing to
Google for!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.pm.org/pipermail/melbourne-pm/attachments/20190322/03ecce3c/attachment.html>

More information about the Melbourne-pm mailing list