Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customized Dexterity edit form template in Plone?

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:

  1. Have an edit for that is wrapped in a bare template that essentially just includes the content inside the #content div.
  2. I do not want merely an unwrapped z3c.form rendering, I need a minimal template to wrap it too -- just not the stock Plone viewlet managers and furntiture.

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.

like image 576
sdupton Avatar asked Aug 27 '12 15:08

sdupton


1 Answers

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')
like image 87
David Glick Avatar answered Sep 28 '22 08:09

David Glick