Skip to content
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 implementation for sub form adapter #116

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
2.0.2 (unreleased)
------------------

- Nothing changed yet.
- Fix sub form adapter implementation. `#114 <https://github.com/collective/collective.z3cform.datagridfield/issues/114>_`.
[thomasmassmann]


2.0.1 (2021-07-28)
Expand Down
15 changes: 12 additions & 3 deletions src/collective/z3cform/datagridfield/autoform.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,34 @@
from plone.autoform.form import AutoExtensibleForm
from plone.autoform.interfaces import IAutoExtensibleForm
from z3c.form import action
from z3c.form import form
from z3c.form.error import MultipleErrorViewSnippet
from z3c.form.interfaces import IFormLayer
from z3c.form.interfaces import IMultipleErrors
from z3c.form.interfaces import IObjectWidget
from z3c.form.interfaces import ISubForm
from z3c.form.interfaces import ISubformFactory
from z3c.form.object import ObjectSubForm
from z3c.form.object import SubformAdapter
from zope.component import adapter
from zope.i18nmessageid import Message
from zope.interface import implementer
from zope.interface import Interface


@implementer(ISubForm)
class AutoExtensibleSubForm(AutoExtensibleForm, form.BaseForm):
class AutoExtensibleSubForm(AutoExtensibleForm, ObjectSubForm):

@property
def schema(self):
return self.__parent__.field.schema

def update(self):
# Ensure correct form mode is set
# If not, it will always be input
self.mode = self.__parent__.mode
super(AutoExtensibleSubForm, self).update()


def updateActions(self):
self.actions = action.Actions(self.__parent__, self.request, None)

Expand All @@ -50,7 +59,7 @@ def updateFields(self):
Interface, # field.schema
)
@implementer(ISubformFactory)
class AutoExtensibleSubformAdapter(object):
class AutoExtensibleSubformAdapter(SubformAdapter):
factory = AutoExtensibleSubForm


Expand Down