Defect #35557

Fix position when rendering custom field enumerations

Added by Liane Hampe 3 months ago. Updated 3 months ago.

Status:ConfirmedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Custom fields
Target version:Candidate for next major release
Resolution: Affected version:4.2.1

Description

The position of each custom field enumeration is integrated as hidden
field in the corresponding index.html.erb file.

When iterating over all enumerations for a certain field, the iteration
is done with an index information of the array, what contains all enumerations.

This index information again is used as the value for the position.

This is wrong, since the (array) index starts counting from zero whereas the position
numbers start counting from 1.

This is fixed now by increasing the position by 1 as stated below.

diff --git a/app/views/custom_field_enumerations/index.html.erb b/app/views/custom_field_enumerations/index.html.erb
index 83e9d59c9..45398728f 100755
--- a/app/views/custom_field_enumerations/index.html.erb
+++ b/app/views/custom_field_enumerations/index.html.erb
@@ -7,7 +7,7 @@
   <% @custom_field.enumerations.each_with_index do |value, position| %>
     <li>
       <span class="icon-only icon-sort-handle sort-handle"></span>
-      <%= hidden_field_tag "custom_field_enumerations[#{value.id}][position]", position, :class => 'position' %>
+      <%= hidden_field_tag "custom_field_enumerations[#{value.id}][position]", position + 1, :class => 'position' %>
       <%= text_field_tag "custom_field_enumerations[#{value.id}][name]", value.name, :size => 40 %>
       <%= hidden_field_tag "custom_field_enumerations[#{value.id}][active]", 0 %>
       <label>

History

#1 Updated by Go MAEDA 3 months ago

  • Status changed from New to Confirmed

The topmost position value is 0 when you open /custom_fields/*/enumerations, but it changes to 1 if you reorder values by drag and drop.

#2 Updated by Go MAEDA 3 months ago

  • Target version set to Candidate for next major release

Also available in: Atom PDF