[Erp5-report] r13883 - /erp5/trunk/products/ERP5Form/FormulatorPatch.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Apr 3 11:47:51 CEST 2007
Author: romain
Date: Tue Apr 3 11:47:50 2007
New Revision: 13883
URL: http://svn.erp5.org?rev=13883&view=rev
Log:
Do not lose entered value in a DateTimeField when form validation fails (only if the fields default to now).
Modified:
erp5/trunk/products/ERP5Form/FormulatorPatch.py
Modified: erp5/trunk/products/ERP5Form/FormulatorPatch.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/FormulatorPatch.py?rev=13883&r1=13882&r2=13883&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/FormulatorPatch.py (original)
+++ erp5/trunk/products/ERP5Form/FormulatorPatch.py Tue Apr 3 11:47:50 2007
@@ -699,6 +699,8 @@
return value
# if there is something in the request then return None
# sub fields should pick up defaults themselves
+ # XXX hasattr(REQUEST, 'form') seems useless, because REQUEST always has
+ # a form property
if REQUEST is not None and hasattr(REQUEST, 'form') and \
REQUEST.form.has_key('subfield_%s_%s' % (key, 'year')):
return None
@@ -750,7 +752,11 @@
# Is it still usefull to test the None value,
# as DateTimeField should be considerer as the other field
# and get an empty string as default value?
- if value in (None, '') and field.get_value('default_now'):
+ # XXX hasattr(REQUEST, 'form') seems useless,
+ # because REQUEST always has a form property
+ if (value in (None, '')) and (field.get_value('default_now')) and \
+ ((REQUEST is None) or (not hasattr(REQUEST, 'form')) or \
+ (not REQUEST.form.has_key('subfield_%s_%s' % (key, 'year')))):
value = DateTime()
year = None
month = None
More information about the Erp5-report
mailing list