【问题标题】:Dexterity Add Form Template敏捷添加表单模板
【发布时间】:2012-11-24 03:15:44
【问题描述】:

我正在尝试在我的敏捷内容类型上创建自定义添加表单。我已按照此链接中的说明进行操作:http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/forms

在我的内容类型中:

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

对于我的模板 businesstransactionformaddform.pt,我使用了此链接中的布局:http://dexterity-developer-manual.readthedocs.org:8000/en/latest/schema-driven-forms/customising-form-presentation/layout-templates.html

我之所以要自定义添加表单,是因为我想插入 jQuery 来计算来自 DataGrid 字段的值。我插入javascript没有问题。唯一的问题是,在网页上,它创建了两个表单,分别位于上、下,即相同类型的字段被复制到另一个的底部。我使用的模板有问题吗?有谁知道添加视图的正确模板是什么?谢谢!

【问题讨论】:

    标签: python plone dexterity


    【解决方案1】:

    Dexterity 假定添加表单的模板只是用于表单而不是整个页面,因此它采用表单模板并将其包装在另一个使用 main_template 的模板中。

    由于您的自定义模板会呈现整个页面,因此您应该使用 form.wrap 指令关闭包装:

    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)
    

    【讨论】:

    • 非常感谢!这正是我所需要的。你拯救了我的一天。
    猜你喜欢
    • 2017-05-05
    • 2011-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多