[Erp5-report] r31460 jp - /erp5/trunk/products/ERP5Form/MatrixBox.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Dec 24 15:13:39 CET 2009
Author: jp
Date: Thu Dec 24 15:13:37 2009
New Revision: 31460
URL: http://svn.erp5.org?rev=31460&view=rev
Log:
Make sure that the values entered by the user in the matrixbox are displayed in priority whenever the form has any error (even outside the matrixbox).
Modified:
erp5/trunk/products/ERP5Form/MatrixBox.py
Modified: erp5/trunk/products/ERP5Form/MatrixBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/MatrixBox.py?rev=31460&r1=31459&r2=31460&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/MatrixBox.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/MatrixBox.py [utf8] Thu Dec 24 15:13:37 2009
@@ -352,11 +352,16 @@
if render_format=='html':
display_value = attribute_value
-
- if field_errors.has_key(key):
- # Display previous value (in case of error)
+ if field_errors:
+ # Display previous value in case of any error
+ # in this form because we have no cell to get
+ # value from
display_value = REQUEST.get('field_%s' % key,
attribute_value)
+ else:
+ display_value = attribute_value
+ if field_errors.has_key(key):
+ # Display error message if this cell has an error
has_error = 1
cell_body += '<span class="input">%s</span>%s' % (
my_field.render(value=display_value,
@@ -366,7 +371,7 @@
else:
cell_body += '<span class="input">%s</span>' %\
my_field.render(
- value=attribute_value,
+ value=display_value,
REQUEST=REQUEST,
key=key)
@@ -378,8 +383,28 @@
attribute_value = my_field.get_value('default', cell=None,
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))
+ if field_errors:
+ # Display previous value in case of any error
+ # in this form because we have no cell to get
+ # value from
+ display_value = REQUEST.get('field_%s' % key,
+ attribute_value)
+ else:
+ display_value = attribute_value
+ if field_errors.has_key(key):
+ # Display error message if this cell has an error
+ has_error = 1
+ cell_body += '<span class="input">%s</span>%s' % (
+ my_field.render(value=display_value,
+ REQUEST=REQUEST,
+ key=key),
+ translateString(field_errors[key].error_text))
+ else:
+ cell_body += '<span class="input">%s</span>' %\
+ my_field.render(
+ value=display_value,
+ REQUEST=REQUEST,
+ key=key)
elif render_format == 'list':
list_result_lines.append(None)
More information about the Erp5-report
mailing list