Skip to content

Commit

Permalink
Portlet add and edit forms AutoExtensibleForm. But some portlet addfo…
Browse files Browse the repository at this point in the history
…rms fail on creating the Assignment, if there is a FormExtender for the form,

and the addform uses "Assignment(**data)" for creation and not "Assignment(key=data.get(key, None))".
Fix this by filtering away data values that does not come from the 'core' schema.
  • Loading branch information
sunew committed Jun 20, 2018
1 parent 361be42 commit d7510b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Bug fixes:

- Test against plone.app.contenttypes instead of ATContentTypes.
[davisagli]
- Portlet add and edit forms AutoExtensibleForm. But some portlet
addforms fail on creating the Assignment, if there is a FormExtender
for the form, and the addform uses "Assignment(**data)" for creation
and not "Assignment(key=data.get(key, None))". Fix this by filtering
away data values that does not come from the 'core' schema.
[sunew]

4.3.1 (2017-08-07)
Expand Down
10 changes: 9 additions & 1 deletion plone/app/portlets/browser/formhelper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from z3c.form import button
from z3c.form import field
from z3c.form import form
from zope.component import getMultiAdapter
from zope.interface import implementer
Expand Down Expand Up @@ -60,7 +61,14 @@ def __call__(self):
return super(AddForm, self).__call__()

def createAndAdd(self, data):
obj = self.create(data)
# Filter away data values that does not come from the 'core' schema.
# Additional values can come from AutoExtensibleForm/FormExtender schemas,
# and the portlet Assignment creation will fail if using "Assignment(**data)".
# Extender values are set in form.applyChanges below.
schema_keys = field.Fields(self.schema).keys()
unextended_data = { key: data[key] for key in schema_keys if data.has_key(key)}

obj = self.create(unextended_data)

# Acquisition wrap temporarily to satisfy things like vocabularies
# depending on tools
Expand Down

0 comments on commit d7510b4

Please sign in to comment.