[ic] How to sett toggle ?

Jon Jensen interchange-users@interchange.redhat.com
Fri Dec 21 11:20:01 2001


On Fri, 21 Dec 2001, Kaare Rasmussen wrote:

> <form action="[process]" method="post">
> <input type=hidden name="mv_nextpage" value="[var MV_PAGE 1]">
> [set test]
> [if scratch vat_display][set vat_display][/set][else][set
> vat_display]1[/set][/else][/if]
> mv_todo=return
> [/set]
> <INPUT TYPE=submit NAME=mv_click VALUE="test">
> </form>
>
> But for more complex pages as flypage, that has to know which product it's
> displaying, it looses this information and shows up a wrong page with ic
> tags that doesn't know what they're supposed to do.
>
> Maybe there is a simple solution, but I can't find it. Please help, someone.

I don't know of a simple way -- you probably just need to pass all the CGI
variables in the form. How about a simple usertag like this:

UserTag form_hidden addAttr
UserTag form_hidden Routine <<EOR
sub {
	my ($opt) = @_;
	return unless $opt->{cgi};
	my $cgi;
	if ($opt->{cgi} eq '1') {
		$cgi = $CGI;
	}
	else {
		$cgi = {};
		for (split ' ', $opt->{cgi}) {
			$cgi->{$_} = $CGI->{$_} if defined $CGI->{$_};
		}
	}
	my $form = '';
	$form .= qq{<input type=hidden name="$_" value="$cgi->{$_}">\n}
		for keys %$cgi;
	return $form;
}
EOR

Then change your form to look like this:

<form action="[process]" method=post>
[cgi name="mv_nextpage" set="[var MV_PAGE 1]" hide=1]
[form_hidden cgi=1]
[set test]
[if scratch vat_display][set vat_display][/set][else][set vat_display]1[/set][/else][/if]
mv_todo=return
[/set]
<input type=submit name="mv_click" value=test>
</form>

And if you don't actually want to pass on *all* CGI parameters, you can
instead do:

[form_hidden cgi="mv_nextpage some_cgi another_one"]

and so on.

I actually tested this, and it works. :)

Jon