问题描述
我有一个接口类,一个映射到后端数据库的类以及一个form.SchemaForm类.
I have an interface class, an class mapped to a back end database, and a form.SchemaForm class.
这是我的界面.
class IAsset(form.Schema):
"""Interface class of an asset
"""
...
Options = schema.Text.....
Parent = schema.Int(title=u"Parent",
required=False
)
Status = schema.Choice.....
我认为ORM类没有任何实例,但这是我的SchemaForm的一部分.
I don't think the ORM class is of any instance, but here is a bit of my SchemaForm.
class AddAsset(form.SchemaForm):
grok.name('add-asset')
grok.require('zope2.View')
grok.context(ISiteRoot)
schema = IAsset
ignoreContext = True
....
@button.buttonAndHandler(u"Select Parent Asset")
#open parent form to select a parent asset
我想将按钮重新定位在父项下方,而不是在表单底部.这可能还是我必须创建某种模板文件?
I would like to reposition the button to be below parent instead of at the bottom of the form. Is this possible or would I have to create some sort of template file?
推荐答案
如果要重新发布按钮,则必须使用自己的模板.
If you want to repostion your button you have to use your own template.
在z3c.form中,您可以按照以下示例进行操作.
In z3c.form you can do this by following this example.
from z3c.form import form
class MyForm(form.Form):
template = ViewPageTemplateFile('templates/custom_template.pt')
在模板中,您可以手动访问表单的所有部分.
In the template you can access all parts of the form manually.
在您的情况下,您可以简单地渲染孔形状,而将零件插入formtop
槽中.
In your case you could simple render the hole form and but your part into the formtop
slot.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="plone"
metal:use-macro="context/main_template/macros/master">
<metal:block fill-slot="top_slot"
tal:define="dummy python:request.set('disable_border',1);
dummy python:request.set('disable_plone.leftcolumn', 1);
dummy python:request.set('disable_plone.rightcolumn', 1);
" />
<metal:block fill-slot="main">
<metal:form use-macro="context/@@ploneform-macros/form">
<metal:topslot fill-slot="formtop">
<!-- Implement your action here. -->
</metal:topslot
</metal:form>
</<metal:block>
</html>
通常使用plone.app.z3cform中定义的形式.检查此 https://github .com/plone/plone.app.z3cform/blob/36586431ed8e067c761e33c725758ce2c1b460f8/plone/app/z3cform/templates/macros.pt 以获得详细信息.
Usually the form defined in plone.app.z3cform is used. Check this https://github.com/plone/plone.app.z3cform/blob/36586431ed8e067c761e33c725758ce2c1b460f8/plone/app/z3cform/templates/macros.pt for detailed information.
这篇关于Plone/form.SchemaForm-如何在SchemaForm中重新放置按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!