$auth->assert('part_service_assembly_edit');
- my ($parts_id, %newform, $previousform, $amount, $callback);
+ my ($parts_id, %newform, $amount, $callback);
# check if there is a part number - commented out, cause there is an automatic allocation of numbers
# $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
# save the new form variables before splitting previousform
map { $newform{$_} = $form->{$_} } keys %$form;
- $previousform = $form->unescape($form->{previousform});
-
# don't trample on previous variables
map { delete $form->{$_} } keys %newform;
my $ic_cvar_configs = CVar->get_configs(module => 'IC');
my @ic_cvar_fields = map { "cvar_$_->{name}" } @{ $ic_cvar_configs };
- # now take it apart and restore original values
- foreach my $item (split /&/, $previousform) {
- my ($key, $value) = split m/=/, $item, 2;
- $value =~ s/%26/&/g;
- $form->{$key} = $value;
- }
+ # restore original values
+ $::auth->restore_form_from_session($newform{previousform}, form => $form);
$form->{taxaccounts} = $newform{taxaccount2};
if ($form->{item} eq 'assembly') {
$form->{old_callback} = $form->escape($form->{callback}, 1);
$form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
- # save all form variables except action in a previousform variable
- my $previousform = join '&', map { my $value = $form->{$_}; $value =~ s/&/%26/; "$_=$value" } grep { !/action/ } keys %$form;
+ # save all form variables except action in the session and keep the key in the previousform variable
+ my $previousform = $::auth->save_form_in_session(skip_keys => [ qw(action) ]);
my @HIDDENS;
- push @HIDDENS, { 'name' => 'previousform', 'value' => $form->escape($previousform, 1) };
+ push @HIDDENS, { 'name' => 'previousform', 'value' => $previousform };
push @HIDDENS, map +{ 'name' => $_, 'value' => $form->{$_} }, qw(rowcount vc);
push @HIDDENS, map +{ 'name' => $_, 'value' => $form->{"${_}_$form->{rowcount}"} }, qw(partnumber description unit);
push @HIDDENS, { 'name' => 'taxaccount2', 'value' => $form->{taxaccounts} };