我正在使用z3c.form创建一个表单,对于textarea,我希望有一个所见即所得的界面。
所以我使用plone.directives.form来处理它。
在我的interfaces.py中:
from zope import schema
from plone.directives import form
from plone.app.z3cform.wysiwyg import WysiwygFieldWidget
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('BSWMinisite')
class IMinisiteProperties(form.Schema):
""" """
form.widget(edito=WysiwygFieldWidget)
edito = schema.Text(title = u"Edito",
required=False)
在我的content.py中:
from plone.directives import form
from z3c.form import button
from Products.CMFPlone import PloneMessageFactory as plMF
from plone.z3cform.layout import wrap_form
from Products.CMFCore.utils import getToolByName
from Products.BSWMinisite.interfaces import IMinisiteProperties
class MinisitePropertiesForm(form.SchemaForm):
""" """
schema = IMinisiteProperties
ignoreContext = True # don't use context to get widget data
@button.buttonAndHandler(plMF('label_save', default=u'Save'), name='apply')
def handleApply(self, action):
""" stuff """
@button.buttonAndHandler(plMF('label_cancel', default=u'Cancel'),
name='cancel')
def handleCancel( self, action):
self.request.RESPONSE.redirect( self.context.absolute_url() )
MinisitePropertiesView = wrap_form(MinisitePropertiesForm)
在configure.zcml中我有:
<include package="plone.directives.form" file="meta.zcml" />
<include package="plone.directives.form" />
<browser:page
for="*"
name="minisite_properties"
class=".browser.content.MinisitePropertiesView"
permission="cmf.ModifyPortalContent"
/>
当我去@@ minisite_properties时,我看到了我的领域,但没有任何所见即所得。 你知道我错过了什么吗?
答案 0 :(得分:2)
下面是使用Dexterity 1.1 pindowns的Dexterity内容模式的示例代码(参见敏捷手册,安装部分)
from five import grok
from zope import schema
from plone.directives import form, dexterity
from plone.app.z3cform.wysiwyg import WysiwygFieldWidget
class ICourseInfoContent(form.Schema):
"""
Content page for CourseInfo folders
"""
# Autofilled by course id
title = schema.TextLine(title=u"Title", required=True, default=u"")
# -*- Your Zope schema definitions here ... -*-
form.widget(body=WysiwygFieldWidget)
body = schema.Text(title=u"Body (top)")
答案 1 :(得分:0)
所以,问题是我没有正确的灵巧版本,而且我的包裹没有正确理解。
在构建中,要固定正确的灵活性:
extends =
base.cfg
versions.cfg
http://good-py.appspot.com/release/dexterity/1.1?plone=4.1.3
在主configure.zcml中:
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:grok="http://namespaces.zope.org/grok"
i18n_domain="BSWMinisite">
<!-- Grok the package to initialise schema interfaces and content classes -->
<grok:grok package="." />
<browser:page
for="*"
name="minisite_properties"
class=".browser.content.MinisitePropertiesView"
permission="cmf.ModifyPortalContent"
/>
...
然后在我的content.py中:
from five import grok
class MinisitePropertiesForm(form.SchemaForm):
""" """
grok.context(IMinisiteProperties)
schema = IMinisiteProperties