Question

I'm trying to create a customised add form on my dexterity content type. I have followed the instructions from this link: http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/forms

In my content type:

class BusinessTransactionFormAddForm(dexterity.AddForm):
    grok.name('ebpls.app.businesstransactionform')

For my template, businesstransactionformaddform.pt I have used the layout from this link: http://dexterity-developer-manual.readthedocs.org:8000/en/latest/schema-driven-forms/customising-form-presentation/layout-templates.html

The reason why I wanted to customize the add form, it's because I wanted to insert jQuery to compute the values from a DataGrid Field. I have no problem with inserting the javascript. The only problem is that, on the web page, it creates two forms, positioned at the upper and lower, i.e. the same kind of fields were replicated at the bottom part of the other. Is there something wrong with the template that I used? Does anyone know what is the right template for the add view? Thanks!

Was it helpful?

Solution

Dexterity assumes that the template of an add form is just for the form and not the entire page—so it takes the form template and wraps it in another template that uses main_template.

Since your custom template does render the entire page, you should turn off the wrapping using the form.wrap directive:

from five import grok
from plone.directives import form
from plone.directives import dexterity

class BusinessTransactionFormAddForm(dexterity.AddForm):
    grok.name('ebpls.app.businesstransactionform')
    form.wrap(False)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top