Commits

Chris Perkins  committed 85a615a

fixes.

  • Participants
  • Parent commits 86c5b23

Comments (0)

Files changed (3)

File src/tgext/subform/controller.py

     @expose('json')
     def validate(self, *args, **kw):
         model = self.model
+        subtype = kw['__subtype']
+        method = kw.get('__method', 'add')
+        form = self.edit_form
+        if method == 'add':
+            form = self.new_form
         
-        if '__subtype' in kw:
-            model = self._get_subtype(kw['__subtype'])
-            del kw['__subtype']
-            #xxx: return invalid subtype if model is none
-            
-        #xxx:figure out how to make this work appropriately with the parent's form types
-        ValidatingFormType = AddRecordForm
-        if '__method' in kw and kw['method']=='edit':
-            ValidatingFormType = EditableForm
-            del kw['__method']
-        
-        class ValidatingForm(ValidatingFormType):
-            __entity__ = model
-        
-        vform = ValidatingForm(self.session)
+        widget = form.__widget__.children[subtype]
         
         try:
-            vform.validate(kw)
+            v = widget.__subform__.validate(kw)
         except Invalid as e:
             return e.unpack_errors()
         return {}

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

     var name = item[display_field_name];
     
     //find the select field that share's the wrapper's (great-)*grandparent
-    var selectfield = wrapper.parentNode.parentNode.children[0];
+    var selectfield = dojo.query('select#'+this.config.subtype)[0]
     
     var option = dojo.create('option');
     option.value = value;
             toggleSubForm(subform.config.form_id);
             subform.addOption(response, true);
             subform.updateRelatedSubForms(response);
-        },
-        error: function(response, ioArgs) { 
+        }//,
+        /*error: function(response, ioArgs) { 
             console.error("HTTP status code: ", ioArgs.xhr.status);
             return false;
-        }
+        }*/
     });
 
 };

File src/tgext/subform/widgets.py

 import inspect
 from formencode import Invalid
+from formencode.validators import Email
 from tw.core import Widget, JSLink, CSSLink
 from tw.forms import SubmitButton
 from tw.dojo import dojo_js
     params = {'__field_widget_types__':{}, 
               '__field_validator_types__':{}, 
               '__base_widget_args__':{},
+              '__base_widget_args__':{},
+              '__omit_fields__':None,
               'related_subforms':'',
               'add_record_form_type':''
               }
         fvt = self.__field_validator_types__ or {}
         bwa = {'id':subform_id}
         bwa.update(self.__base_widget_args__ or {})
+        of = self.__omit_fields__ or None
 
         
         class ARF(self.add_record_form_type):
             __entity__ = target
             __field_widget_types__ = fwt
             __field_validator_types__ = fvt
+            __omit_fields__ = of
         
         return ARF(self.provider.session)