Custom AddForm Template with Agility, on Plone 4

I'm having trouble getting the Dexterity content type to show a custom upload form. I already did this in the previous product, but, surprisingly, I can not accomplish this using Plone 4.1 and plone.app.dexterity 1.0.3

The content type My CrmContact, living in package.name.types.contact.py, has its own schema defined as follows:

from five import grok from zope import schema from zope.interface import implements from plone.directives import form, dexterity class ICrmContact(form.Schema): """A contact item for the CRM""" title = schema.TextLine( title=_(u"Company name"), ) ... class CrmContact(dexterity.Container): implements(ICrmContact) class Add(dexterity.AddForm): grok.context(ICrmContact) grok.name('package.name.contacts.types.contact') grok.template('add') 

My template is located in the / name / types / contact _templates folder. This is a typical pattern. I know this is not being displayed because it has a dummy node that will call a non-existent method using tal: content to throw an exception; therefore, I am sure that the template itself is not a problem.

My FTI content type is registered correctly during installation, and the content type is available and added.

Finally, in the /default/types.package.name.types.contact.xml profiles:

 <?xml version="1.0"?> <object name="package.name.types.contact" meta_type="Dexterity FTI" i18n:domain="package.name" xmlns:i18n="http://xml.zope.org/namespaces/i18n"> ... <!-- Method aliases --> <alias from="(Default)" to="(dynamic view)" /> <alias from="edit" to="@@edit" /> <alias from="sharing" to="@@sharing" /> <alias from="view" to="(selected layout)" /> <!-- Actions --> <action title="View" action_id="view" category="object" condition_expr="" url_expr="string:${object_url}" visible="True"> <permission value="View" /> </action> <action title="Edit" action_id="edit" category="object" condition_expr="" url_expr="string:${object_url}/edit" visible="True"> <permission value="Modify portal content" /> </action> </object> 

Unrelated, but maybe I need to add something here ...

I think I followed the correct procedure, as you can see, but I still cannot get it to work.

I know that the Add class gets instanced, because if I provide the updateWidgets () method and insert a breakpoint, it is called; and when I examine the object, self.template is None; although:

 (Pdb) getattr(self, 'grokcore.view.directive.template') 'add' 

How can I create a custom template in the form of adding my custom type?

+4
source share
1 answer

You must remove the grok.context(ICrmContact) .

From http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/forms :

Also note that we do not indicate context here. Add forms are always registered for any IFolderish context.

+1
source

Source: https://habr.com/ru/post/1380533/


All Articles