From 7fd36c8fdef438a233c9729277dcecc4d8581f28 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Wed, 2 Mar 2005 18:15:21 +0000
Subject: [PATCH] Bug fix: correct error in render when no cell exists.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2627 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/MatrixBox.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/product/ERP5Form/MatrixBox.py b/product/ERP5Form/MatrixBox.py
index 1e652639ceb..3078c7e88bd 100755
--- a/product/ERP5Form/MatrixBox.py
+++ b/product/ERP5Form/MatrixBox.py
@@ -291,12 +291,16 @@ class MatrixBoxWidget(Widget.Widget):
                         list_result_lines.append(attribute_value)
 
                   else:
-                    if render_format == 'html': 
-                      # XXX no cell exists, we need to display a correct field, without generate plenty of errors...
-                      cell_body += str(my_field.render(value = None, REQUEST=REQUEST, key=key))
+                    if my_field.get_value('hidden'):
+                      attribute_value = my_field.get_value('default', cell_index = kw, cell_position = (i,j, k))
+                      if render_format == 'html': 
+                        cell_body += str(my_field.render(value = attribute_value, REQUEST=REQUEST, key=key))
 
-                    elif render_format == 'list': 
-                      if not my_field.get_value('hidden'):
+                    else:
+                      if render_format == 'html': 
+                        cell_body += str(my_field.render(value = my_field.get_orig_value('default')  , REQUEST=REQUEST, key=key))
+
+                      elif render_format == 'list': 
                         list_result_lines.append(None)
                     
               list_body = list_body + \
@@ -374,7 +378,9 @@ class MatrixBoxValidator(Validator.Validator):
               kwd = {}
               kwd['base_id'] = cell_base_id
               cell = getter_method(*kw, **kwd)
+
               for attribute_id in editable_attribute_ids:
+
                 my_field_id = '%s_%s' % (field.id, attribute_id)
                 if form.has_field(my_field_id):
                   my_field = form.get_field(my_field_id)
@@ -383,10 +389,6 @@ class MatrixBoxValidator(Validator.Validator):
                                                       cell_position = (i,j, k))
                   value = my_field.validator.validate(my_field, key, REQUEST)
 
-                  # XXX Dirty patch, but it was hurry that membership_criterion_category_list field works to generate predicate
-                  if attribute_id == 'membership_criterion_category_list':
-                    value = attribute_value
-
                   if attribute_value != value and not my_field.get_value('hidden'):
                     # Only validate modified values from visible fields
                     if not result.has_key(kw):
-- 
2.30.9