--- a/src/pyams_form/form.py Wed Apr 15 15:00:56 2015 +0200
+++ b/src/pyams_form/form.py Wed Apr 15 15:01:43 2015 +0200
@@ -267,13 +267,14 @@
registry = self.request.registry
# create object
object = self.create(data)
- registry.notify(ObjectCreatedEvent(object))
- # set parent temporarily to avoid NotYet exceptions
- locate(object, self.context)
- # update object properties before adding it
- self.update_content(object, data)
- self.add(object)
- registry.notify(FormObjectCreatedEvent(object, self))
+ if object is not None:
+ registry.notify(ObjectCreatedEvent(object))
+ # set parent temporarily to avoid NotYet exceptions
+ locate(object, self.context)
+ # update object properties before adding it
+ self.update_content(object, data)
+ self.add(object)
+ registry.notify(FormObjectCreatedEvent(object, self))
return object