[Checkins] SVN: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/ avoid to initialize value with empty string since client validation will fail at render time if an empty value is given when 'allowBlank' is false

Laurent Mignon Laurent.Mignon at softwareag.com
Thu Mar 19 03:38:14 EDT 2009


Log message for revision 98253:
  avoid to initialize value with empty string since client validation will fail at render time if an empty value is given when 'allowBlank' is false

Changed:
  U   z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py
  U   z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.txt
  U   z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt
  U   z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py

-=-
Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py	2009-03-19 06:08:16 UTC (rev 98252)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py	2009-03-19 07:38:14 UTC (rev 98253)
@@ -63,8 +63,10 @@
         config = dict(
             name = self.widget.name,
             fieldLabel = self.widget.label,
-            id = self.widget.id,
-            value = self.widget.value)
+            id = self.widget.id)
+        value = self.widget.value
+        if value is not None and value != "":
+            config["value"] = self.widget.value
         if self.xtype:
             config['xtype'] = self.xtype
         title = self.widget.title
@@ -201,7 +203,7 @@
         config.update(dict(
             hiddenName = config['name']+':list',
             triggerAction = 'all',
-            editable = False,
+            editable = True,
             store= [(item['value'], item['content'])
                 for item in self.widget.items],
             ))
@@ -290,8 +292,9 @@
     def _getConfig(self, json=False):
         config = super(Button, self)._getConfig()
         config['text'] = self.widget.value
-        del config['value']
         del config['fieldLabel']
+        if 'value' in config:
+            del config['value']
         return config
 
 

Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.txt
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.txt	2009-03-19 06:08:16 UTC (rev 98252)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.txt	2009-03-19 07:38:14 UTC (rev 98253)
@@ -65,7 +65,6 @@
    'itemCls': 'required',                                                                                          
    'minLength': 0,                                                                                                 
    'name': 'label',                                                                                                
-   'value': u'',                                                                                        
    'xtype': 'textfield'}
   
   >>> labelWidget.request = TestRequest(form = {'label': 'widget value'})
@@ -118,7 +117,6 @@
    'maxLength': 200,
    'minLength': 1,
    'name': 'label',
-   'value': u'',
    'xtype': 'textfield'}
 
 Let's test config for a lot of possible fields
@@ -222,7 +220,7 @@
   ...     IFieldWidget)
   >>> choiceWidget.update()
   >>> pprint(interfaces.IExtJSComponent(choiceWidget).getConfig())
-  {'editable': False,
+  {'editable': True,
    'fieldLabel': u'Choice',
    'hiddenName': 'choiceField:list',
    'id': 'choiceField',
@@ -244,7 +242,7 @@
   ...     IFieldWidget)
   >>> choiceWidget.update()
   >>> pprint(interfaces.IExtJSComponent(choiceWidget).getConfig())
-  {'editable': False,                                                                                               
+  {'editable': True,                                                                                               
    'fieldLabel': u'Choice (Not Required)',                                                                          
    'hiddenName': 'optionalChoiceField:list',                                                                        
    'id': 'optionalChoiceField',                                                                                     
@@ -620,7 +618,6 @@
    'itemCls': 'required',
    'minLength': 0,
    'name': 'form.widgets.id',
-   'value': u'',
    'xtype': 'textfield'}
 
 Here is a single checkbox widget
@@ -642,13 +639,12 @@
    'itemCls': 'required',
    'minLength': 0,
    'name': 'form.widgets.name',
-   'value': u'',
    'xtype': 'textfield'}
 
 Here is a select widget
 
   >>> pprint(config['items'][3])
-  {'editable': False,
+  {'editable': True,
    'fieldLabel': u'Gender',
    'hiddenName': 'form.widgets.gender:list',
    'id': 'form-widgets-gender',
@@ -738,7 +734,6 @@
    'itemCls': 'required',
    'minLength': 0,
    'name': 'form.widgets.id',
-   'value': u'',
    'xtype': 'textfield'}
 
 
@@ -770,5 +765,4 @@
    'itemCls': 'required',
    'minLength': 0,
    'name': 'form.widgets.id',
-   'value': u'',
    'xtype': 'my-component'}

Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt	2009-03-19 06:08:16 UTC (rev 98252)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt	2009-03-19 07:38:14 UTC (rev 98253)
@@ -132,7 +132,6 @@
       'itemCls': 'required',                                                                                  
       'minLength': 0,                                                                                         
       'name': 'form.widgets.firstName',                                                                       
-      'value': u'',                                                                                           
       'xtype': 'textfield'},                                                                                  
      {'allowBlank': False,                                                                                    
       'fieldLabel': u'Last Name',                                                                             
@@ -140,7 +139,6 @@
       'itemCls': 'required',                                                                                  
       'minLength': 0,                                                                                         
       'name': 'form.widgets.lastName',
-      'value': u'',
       'xtype': 'textfield'},
      {'items': [{'allowBlank': False,
                  'fieldLabel': u'License',
@@ -148,7 +146,6 @@
                  'itemCls': 'required',
                  'minLength': 0,
                  'name': 'form.widgets.license',
-                 'value': u'',
                  'xtype': 'textfield'},
                 {'allowBlank': False,
                  'fieldLabel': u'Address',
@@ -156,7 +153,6 @@
                  'itemCls': 'required',
                  'minLength': 0,
                  'name': 'form.widgets.address',
-                 'value': u'',
                  'xtype': 'textfield'}],
       'title': u'License',
       'xtype': 'panel'},
@@ -166,7 +162,6 @@
                  'itemCls': 'required',
                  'minLength': 0,
                  'name': 'form.widgets.model',
-                 'value': u'',
                  'xtype': 'textfield'},
                 {'allowBlank': False,
                  'fieldLabel': u'Make',
@@ -174,7 +169,6 @@
                  'itemCls': 'required',
                  'minLength': 0,
                  'name': 'form.widgets.make',
-                 'value': u'',
                  'xtype': 'textfield'},
                 {'allowBlank': False,
                  'fieldLabel': u'Year',
@@ -182,7 +176,6 @@
                  'itemCls': 'required',
                  'minLength': 0,
                  'name': 'form.widgets.year',
-                 'value': u'',
                  'xtype': 'textfield'}],
       'title': u'Car',
       'xtype': 'panel'}]
@@ -290,7 +283,6 @@
                         'itemCls': 'required',                                                             
                         'minLength': 0,                                                                    
                         'name': 'form.widgets.firstName',                                                  
-                        'value': u'',                                                                      
                         'xtype': 'textfield'},                                                             
                        {'allowBlank': False,                                                               
                         'fieldLabel': u'Last Name',                                                        
@@ -298,7 +290,6 @@
                         'itemCls': 'required',                                                             
                         'minLength': 0,                                                                    
                         'name': 'form.widgets.lastName',                                                   
-                        'value': u'',                                                                      
                         'xtype': 'textfield'}],                                                            
              'title': 'Person',                                                                            
              'xtype': 'fieldset'},                                                                         
@@ -308,7 +299,6 @@
                                    'itemCls': 'required',
                                    'minLength': 0,
                                    'name': 'form.widgets.license',
-                                   'value': u'',
                                    'xtype': 'textfield'},
                                   {'allowBlank': False,
                                    'fieldLabel': u'Address',
@@ -316,7 +306,6 @@
                                    'itemCls': 'required',
                                    'minLength': 0,
                                    'name': 'form.widgets.address',
-                                   'value': u'',
                                    'xtype': 'textfield'}],
                         'title': u'License',
                         'xtype': 'panel'},
@@ -326,7 +315,6 @@
                                    'itemCls': 'required',
                                    'minLength': 0,
                                    'name': 'form.widgets.model',
-                                   'value': u'',
                                    'xtype': 'textfield'},
                                   {'allowBlank': False,
                                    'fieldLabel': u'Make',
@@ -334,7 +322,6 @@
                                    'itemCls': 'required',
                                    'minLength': 0,
                                    'name': 'form.widgets.make',
-                                   'value': u'',
                                    'xtype': 'textfield'},
                                   {'allowBlank': False,
                                    'fieldLabel': u'Year',
@@ -342,7 +329,6 @@
                                    'itemCls': 'required',
                                    'minLength': 0,
                                    'name': 'form.widgets.year',
-                                   'value': u'',
                                    'xtype': 'textfield'}],
                         'title': u'Car',
                         'xtype': 'panel'}],

Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py	2009-03-19 06:08:16 UTC (rev 98252)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py	2009-03-19 07:38:14 UTC (rev 98253)
@@ -121,7 +121,6 @@
     zope.interface.classImplements(BaseForm, interfaces.IBaseForm)
     zope.component.provideAdapter(converter.ExtJSDateDataConverter)
     zope.component.provideAdapter(converter.ExtJSSingleCheckBoxDataConverter)
-    zope.component.provideAdapter(converter.SingleCheckBoxDataConverter)
 
 
 class Context(object):



More information about the Checkins mailing list