Commit e7681e38 authored by Jérome Perrin's avatar Jérome Perrin

override manage_renameObject to keep the ordering of a field in a form after

renaming a field


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24150 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6a344d81
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
from copy import deepcopy
from Products.Formulator.Form import Form, BasicForm, ZMIForm from Products.Formulator.Form import Form, BasicForm, ZMIForm
from Products.Formulator.Form import manage_addForm, manage_add, initializeForm from Products.Formulator.Form import manage_addForm, manage_add, initializeForm
from Products.Formulator.Errors import FormValidationError, ValidationError from Products.Formulator.Errors import FormValidationError, ValidationError
...@@ -574,6 +576,19 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -574,6 +576,19 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
pt = getattr(self,self.pt) pt = getattr(self,self.pt)
return pt._exec(self, bound_names, args, kw) return pt._exec(self, bound_names, args, kw)
def manage_renameObject(self, id, new_id, REQUEST=None):
# overriden to keep the order of a field after rename
groups = deepcopy(self.groups)
ret = ZMIForm.manage_renameObject(self, id, new_id, REQUEST=REQUEST)
for group_id, field_id_list in groups.items():
if id in field_id_list:
index = field_id_list.index(id)
field_id_list.pop(index)
field_id_list.insert(index, new_id)
groups[group_id] = field_id_list
self.groups = groups
return ret
# Utilities # Utilities
def ErrorFields(self, validation_errors): def ErrorFields(self, validation_errors):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment