Commits

Chris Perkins committed b3bae7e

add the ability to add additional fields to the widget.

  • Participants
  • Parent commits 665aee0

Comments (0)

Files changed (2)

src/tgext/subform/static/javascript/select_field_with_add.js

     for (field_name in fields){
         if (fields.hasOwnProperty(field_name)){
             field = fields[field_name];
-            field.value = '';
+            //clear the field if it is not hidden
+            if (field.type != 'hidden'){
+                field.value = '';
+            }
         }
     }
 };

src/tgext/subform/widgets.py

               '__field_validator_types__':{}, 
               '__base_widget_args__':{},
               '__base_widget_args__':{},
+              '__add_fields__':{},
               '__omit_fields__':None,
               'related_subforms':'',
               'add_record_form_type':''
         bwa = {'id':subform_id}
         bwa.update(self.__base_widget_args__ or {})
         of = self.__omit_fields__ or None
+        af = self.__add_fields__ or {}
 
+        af['submit'] = SubmitButton('submit',
+            attrs={'onclick':
+                   "javascript:return function(){%s_helper.validate(); return false;}();"%subform_id})
         
         class ARF(self.add_record_form_type):
-            submit = SubmitButton('submit', 
-                                  attrs={'onclick':"javascript:return function(){"+subform_id+"_helper.validate(); return false;}();"})
             __base_widget_args__ = bwa
             #__base_widget_type__ = TownForm
             __entity__ = target
             __field_widget_types__ = fwt
             __field_validator_types__ = fvt
             __omit_fields__ = of
-        
-        return ARF(self.provider.session)
+            __add_fields__ = af
+
+        subform = ARF(self.provider.session)
+        #if subform_id != 'organization_organization_subform':
+        #    assert 0
+        return subform
     
     @property
     def _display_field_name(self):