Defect #35557

Fix position when rendering custom field enumerations

Added by Liane Hampe 20 days ago. Updated 19 days ago.

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


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


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| %>
       <span class="icon-only icon-sort-handle sort-handle"></span>
-      <%= hidden_field_tag "custom_field_enumerations[#{}][position]", position, :class => 'position' %>
+      <%= hidden_field_tag "custom_field_enumerations[#{}][position]", position + 1, :class => 'position' %>
       <%= text_field_tag "custom_field_enumerations[#{}][name]",, :size => 40 %>
       <%= hidden_field_tag "custom_field_enumerations[#{}][active]", 0 %>


#1 Updated by Go MAEDA 20 days 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 19 days ago

  • Target version set to Candidate for next major release

Also available in: Atom PDF