-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for making the already existing FormExtender feature work #115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall great you made it work! Just some minor style issues.
# -*- coding: utf-8 -*- | ||
|
||
from plone.app.portlets.browser.interfaces import (IPortletAddForm, | ||
IPortletEditForm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see Plone Style Guide https://docs.plone.org/develop/styleguide/python.html#about-imports
applies also below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks:) yep, my isort was missing the recommended plone config (i suggest we add this to the setup.cfg ? )
|
||
class PortletCssClassAdapter(object): | ||
adapts(IPortletAssignment) | ||
implements(IPortletCssClass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use the class decorators @adapter and @Implementer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jensens done
…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.
backport "Fix for making the already existing FormExtender feature work #115" to 4.3.x branch
Portlet add and edit forms already extend AutoExtensibleForm from plone.autoform. (Added in 2014 in fc15814).
That means it is (before this PR) possible to extend portlet forms with a FormExtender.
But some portlet AddForms fail when creating the Assignment, if there is a FormExtender for the form, and the addform uses
Assignment(**data)
for creation instead of explicit parameters.This PR fixes this by filtering away data values that does not come from the 'core' schema.
How to extend the schema of all/one portlet(s)
First define a schema and a formextender:
register it for add and edit forms - in this case for all portlets, but you can be selective on an individual portlet add or edit form interface:
then define an storage adapter for the extended fields. Here I choose to store the data in as PortletAssignmentSettings:
register the storage adapter: