I am working on a Plone add-on that requires a re-skinned alternate edit form for Dexterity content. I need to be able to display only part of the edit form in an AJAX overlay (using JQuery UI, not JQuery tools, so it seems more reasonable to do this server-side than to filter in JavaScript)**.
Documentation from Dexterity Developer's Guide seems to indicate I can have a custom template using macros. Something is missing from this section though -- maybe some critical context for folks not using grok to bind views, but perhaps something else. Creating a template-only view fails (cannot find names from view class, obviously), and attempting to bind a custom template in ZCML to either the stock view class or to a subclass of it both fail (the template is ignored in favor of the stock template).
My goals:
What does not work:
from plone.dexterity.browser.edit import DefaultEditForm
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class MyEditForm(DefaultEditForm):
index = ViewPageTemplateFile('my_edit_template.pt')
The ZCML equivalent (defining the index with runtime magic) also does not work here.
How can I inject a custom template into an edit form?
** I am working on Solgema.fullcalendar compatibility with plone.app.event's Dexterity-based type. Solgema.fullcalendar uses jQuery UI for popups, not plone.app.jquerytools overlay helpers; for consistency, it makes sense to have this minimal view and not attempt to mimic the filter mechanism in JavaScript of normal Plone overlays.
z3c.form looks for the template as the template
attribute, so you need to assign your custom template to the template
attribute of your edit form subclass, rather than index
(which is where the template ZCML attribute puts it).
from plone.dexterity.browser.edit import DefaultEditForm
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class MyEditForm(DefaultEditForm):
template = ViewPageTemplateFile('my_edit_template.pt')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With