Customized Dexterity edit form template in Plone?
Asked Answered
L

1

7

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.

Lakeshialakey answered 27/8, 2012 at 15:38 Comment(2)
In retrospect, this would have been an easier question to answer if you had provided a code sample of what you tried that you thought should work but didn't.Gonfalonier
Agreed, added code example to OP and to answer (pending review).Lakeshialakey
G
9

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')
Gonfalonier answered 27/8, 2012 at 16:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.