in reply to Re: CGI: which field has changed?
in thread CGI: which field has changed?

Yes, I was expecting to have to regenerate, but since there are only four fields plus two or three buttons, I wasn't overly concerned. I read about hidden fields in the CGI docs, but couldn't envisage an application. Thanks to you, I can now! :-)

Regards,

John Davies

Replies are listed 'Best First'.
Re^3: CGI: which field has changed?
by davies (Monsignor) on Mar 14, 2011 at 11:04 UTC

    This actually proved harder than I thought. Partly it was because I did something stupid (CGI: retaining textarea contents in hidden field), but even with this fixed, things didn't work as I expected. My code is now working as I want, but I have the following two lines in my code:

    print hidden(-name => "Old" . $param , -value => $value); param( -name => "Old" . $param , -value => $value);

    I can't find any documentation that indicates that the second line should be needed, but if I leave it out, the values don't get saved. I therefore report this in case anyone else runs into the same problem. Of course, if this should need only one line and I'm doing something else daft, I'd love to know.

    Regards,

    John Davies

      I'm guessing you're missing
      http://search.cpan.org/dist/CGI.pm/lib/CGI.pm#FORM_ELEMENTS
      -override
      A boolean, which, if true, forces the element to take on the value specified by -value, overriding the sticky behavior described earlier for the -nosticky pragma.
      print hidden(-name => "Old" . $param , -value => $value, -override => 1);

        Indeed I was missing it. Thank you kindly.

        Regards,

        John Davies