Subject: | Hidden fields don't appear in current_form if their value="" |
Best way to show this is with an example:
In this HTML snippet:
<form name="aspnetForm" method="post" action="Browse.aspx?
MyToken=632797078501515540" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJ" />
</div>
[...]
</form>
One should see three fields in a $mech->current_form->dump, but one only sees
"__VIEWSTATE".
And of course if one tries to do this:
$mech->set_fields( '__EVENTTARGET' => 'mynewvalue' );
WWW::Mechanize dies:
No such field '__EVENTTARGET' at /Library/Perl/5.8.6/WWW/Mechanize.pm line 1178
I can see why this would be coded, because why store an empty hidden field?
In this case, the site uses javascript to set the field, so they include it in the form as an empty
hiden field, then use JavaScript to fill in the value and do the submit (hack hack).