| Lines 48-59
          my $cache = Koha::Caches->get_instance();
      
      
        Link Here | 
        
          | 48 | # Update data before showing the form | 48 | # Update data before showing the form | 
        
          | 49 | my $no_upd; | 49 | my $no_upd; | 
        
          | 50 |  | 50 |  | 
          
            
              | 51 | if( $input->param('add_field') ) { | 51 | if( $input->param('add_field') && $input->request_method eq 'POST' ) { | 
        
          | 52 |     # add a mapping to all frameworks | 52 |     # add a mapping to all frameworks | 
        
          | 53 |     my ($kohafield, $tag, $sub) = split /,/, $input->param('add_field'), 3; | 53 |     my ($kohafield, $tag, $sub) = split /,/, $input->param('add_field'), 3; | 
          
            
              | 54 |     Koha::MarcSubfieldStructures->search({ tagfield => $tag, tagsubfield => $sub })->update({ kohafield => $kohafield }); | 54 |     my $rs = Koha::MarcSubfieldStructures->search({ tagfield => $tag, tagsubfield => $sub }); | 
            
              |  |  | 55 |     if( $rs->count ) { | 
            
              | 56 |         $rs->update({ kohafield => $kohafield }); | 
            
              | 57 |     } else { | 
            
              | 58 |         $template->param( error_add => 1, error_info => "$tag, $sub" ); | 
            
              | 59 |     } | 
        
          | 55 |  | 60 |  | 
          
            
              | 56 | } elsif( $input->param('remove_field') ) { | 61 | } elsif( $input->param('remove_field') && $input->request_method eq 'POST' ) { | 
        
          | 57 |     # remove a mapping from all frameworks | 62 |     # remove a mapping from all frameworks | 
        
          | 58 |     my ($tag, $sub) = split /,/, $input->param('remove_field'), 2; | 63 |     my ($tag, $sub) = split /,/, $input->param('remove_field'), 2; | 
        
          | 59 |     Koha::MarcSubfieldStructures->search({ tagfield => $tag, tagsubfield => $sub })->update({ kohafield => undef }); | 64 |     Koha::MarcSubfieldStructures->search({ tagfield => $tag, tagsubfield => $sub })->update({ kohafield => undef }); |