Bug 12176: Fix for missing field_value in select
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Sat, 23 May 2015 12:01:57 +0000 (14:01 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 26 May 2015 17:24:39 +0000 (14:24 -0300)
As Jonathan Druart discovered, we were still missing an important attribute
in the selects. Var mv.name was not filled, so the name was empty with nice
side-effects :)
While fixing this, it was also possible to delete some unused vars that Bernardo
already mentioned before: $attributes and $attributes_no_value.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

For me the simptom was different, when saving an edited item
fields were mangled beyond repear :(
No alert for empty mandatory fields.

But this last patch fix the problem.
Tested add/edit items
Cleaner pl file :)
No errors

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt

index 8a800e1..38f5d92 100755 (executable)
@@ -154,7 +154,6 @@ sub generate_subfield_form {
            my $input = new CGI;
            $value = $input->param('barcode');
        }
-        my $attributes_no_value = qq(id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$subfield_data{maxlength}" );
 
         # Getting list of subfields to keep when restricted editing is enabled
         my $subfieldsToAllowForRestrictedEditing = C4::Context->preference('SubfieldsToAllowForRestrictedEditing');
@@ -164,17 +163,6 @@ sub generate_subfield_form {
         ) ? 1 : 0;
         my @subfieldsToAllow = split(/ /, $subfieldsToAllowForRestrictedEditing);
 
-        # If we're on restricted editing, and our field is not in the list of subfields to allow,
-        # then it is read-only
-        $attributes_no_value .= 'readonly="readonly" '
-            if (
-                not $allowAllSubfields
-                and $restrictededition
-                and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
-            );
-
-        my $attributes          = qq($attributes_no_value value="$value" );
-        
         if ( $subfieldlib->{authorised_value} ) {
             my @authorised_values;
             my %authorised_lib;
index b6eedf6..8c4f419 100644 (file)
@@ -231,9 +231,9 @@ $(document).ready(function() {
                     <input type="hidden" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]">
                 [% ELSIF ( mv.type == 'select' ) %]
                     [% IF ( mv.readonlyselect ) %]
-                        <select name="[%- mv.name -%]" id="[%- mv.id -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
+                        <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
                     [% ELSE %]
-                        <select name="[%- mv.name -%]" id="[%- mv.id -%]" size="1" class="input_marceditor">
+                        <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor">
                     [% END %]
                     [% FOREACH aval IN mv.values %]
                         [% IF aval == mv.default %]