Dexterity AddForm

I hope everyone is well. I'm having a problem with dexterity using the AddForm and AddView (on Plone 5.0.4). What makes me so confused is it worked a month ago and now stopped. The EditForm on the dexterity object works perfect but the AddForm isn't being called.

I've looked at all the tuts and other online help posts but with no success such as https://docs.plone.org/external/plone.app.dexterity/docs/advanced/custom-add-and-edit-forms.html and various stackoverflow answers.

Here is my code copied/pasted onto one doc for your convenience (python + configure.zcml)
https://pastebin.com/u3EQi4bE

I'm so lost as to why the update is not triggering now. It is being called by the standard plone toolbars ++add++polklibrary.form.leaverequests.models.leaverequest

Thank you for any help you can provide.

David

So question 1 is: what did you change :wink:

Are you trying to add the content to a non-folder, given that the add view is registered for Products.CMFCore.interfaces.IFolderish?

1 Like

Hear, hear :slight_smile: something must have changed, or the sequence of actions you're taking isn't the same as when it worked...?

I think that should work:

# adapters.py
# -*- coding: utf-8 -*-
from plone.dexterity.browser.add import DefaultAddForm
from plone.dexterity.browser.add import DefaultAddView

class AddForm(DefaultAddForm):
    
    portal_type = 'YOURTYPE'
 
    def update(self):
        print "ADD FORM FIRE!!!!!!!!!!!!"
        DefaultAddForm.update(self)
       
class AddView(DefaultAddView):
    
    form = AddForm
<!-- configure.zcml -->
<adapter
    for="Products.CMFCore.interfaces.IFolderish
         zope.publisher.interfaces.browser.IDefaultBrowserLayer
         plone.dexterity.interfaces.IDexterityFTI"
    provides="zope.publisher.interfaces.browser.IBrowserPage"
    factory=".adapters.AddView"
    name="YOURTYPE"/>
<!-- types/your_schema.xml-->
.....
<property name="factory">YOURTYPE</property>
......
1 Like

What do you mean by the update?

Hi,
I think I have the same problem - I cannot modify the "AddForm" (the EditForm works perfect).

class AddForm(DefaultAddForm):
    portal_type = 'patient'

    def updateWidgets(self):
        super(EditForm, self).updateWidgets()
        logger.info('foo')


class AddView(DefaultAddView):
    form = AddForm
<adapter
    for=".patient.IPatient
         zope.publisher.interfaces.browser.IDefaultBrowserLayer
         plone.dexterity.interfaces.IDexterityFTI"
    provides="zope.publisher.interfaces.browser.IBrowserPage"
    factory=".patient.AddView"
    name="patient"/>

I tried with plone.autoform (AutoExtensibleForm) but nothing works...
btw. EditForm with AutoExtensibleForm works perfect...

The interface definition is for an add form IFolderish

<adapter
    for="Products.CMFCore.interfaces.IFolderish
         zope.publisher.interfaces.browser.IDefaultBrowserLayer
         plone.dexterity.interfaces.IDexterityFTI"
    provides="zope.publisher.interfaces.browser.IBrowserPage"
    factory=".patient.AddView"
    name="patient"/>

not IPatient, see @docs

1 Like

Thank you.
I didn't see it - too heavy copied.... :smirk: