Following the documentation link you provided I managed to override the EditForm and AddForm like:
""" Custom Add/Edit forms
from plone.dexterity.browser import edit
from plone.dexterity.browser import add
from plone.dexterity.utils import getAdditionalSchemata
""" Custom edit form """
for schema in super(EditForm, self).additionalSchemata:
# Custom code here
portal_type = 'magic'
for schema in super(AddForm, self).additionalSchemata:
# Custom code here
form = AddForm
Still, found something interesting digging into the code: The getAdditionalSchemata method called by additionalSchemata has support also for context.
Traceback (innermost last):
* Module ZPublisher.Publish, line 138, in publish
* Module ZPublisher.mapply, line 77, in mapply
* Module ZPublisher.Publish, line 48, in call_object
* Module plone.z3cform.layout, line 63, in __call__
* Module plone.z3cform.layout, line 47, in update
* Module plone.dexterity.browser.add, line 134, in update
* Module plone.z3cform.fieldsets.extensible, line 65, in update
* Module plone.z3cform.patch, line 30, in GroupForm_update
* Module z3c.form.group, line 145, in update
* Module plone.app.z3cform.csrf, line 22, in execute
* Module z3c.form.action, line 98, in execute
* Module z3c.form.button, line 315, in __call__
* Module z3c.form.button, line 170, in __call__
* Module plone.dexterity.browser.add, line 109, in handleAdd
* Module z3c.form.form, line 263, in createAndAdd
* Module plone.dexterity.browser.add, line 76, in create
* Module plone.dexterity.browser.add, line 193, in _applyChanges
* Module z3c.form.datamanager, line 91, in set
* Module z3c.form.datamanager, line 66, in adapted_context
TypeError: ('Could not adapt', <Acquisition.ImplicitAcquisitionWrapper object at 0x7f36bdaa75f0>, <SchemaClass...
Please share if you get this to work, I have a feeling this will be useful one day.
PS: I had a (weird?) user case where I used the add-form to add the 'important fields' and the 'redirect' to the edit form on save (for all the 'not required/optional fields'). Could work as a workaround if everything else fails (?)
Have you seen collective.ambidexterity? Being that it provides TTW (dynamic?) editing abilities for validators, defaults and vocabularies, maybe you could find some inspiration or use the package as a stepping stone for what you want to achieve.
Here you would have several dozen "types" of endpoints, which are individually described. The description could be processed by Plone, and on-the-fly create the required dexterity add and edit forms needed to create, read, update, delete content within the third party platform...