自动完成和浏览 RelationChoice 字段在磁贴中不起作用
Autocomplete and browse for a RelationChoice field are not working in a tile
我有一个带有 RelationChoice
字段的磁贴,但该字段只有静态 html 表单元素(一个 "nothing" 单选按钮、一个文本输入和一个 'Search' 按钮),它不会动态响应。在将它与另一个有效网站上的相同磁贴进行比较时,我注意到来自 plone.formwidget.contenttree 和 plone.formwidget.autocomplete 的特定于字段的 js 代码未嵌入磁贴源中。我在 https://github.com/plone/plone.formwidget.autocomplete/blob/master/plone/formwidget/autocomplete/widget.py#L142 and in https://github.com/plone/plone.formwidget.contenttree/blob/master/plone/formwidget/contenttree/widget.py#L253 中放置了断点,它们在磁贴加载时被击中,并且返回了正确的 js。但是不知道为什么发不给客户端
有什么想法吗?
磁贴上的其他一切正常,标准 jquery 资源已加载:
++resource++plone.formwidget.autocomplete/jquery.autocomplete.min.js
++resource++plone.formwidget.autocomplete/formwidget-autocomplete.js
++resource++plone.formwidget.contenttree/contenttree.js
这是我的图块的 zcml:
<plone:tile
name="peps.tiles.calltoaction"
title="PEPS call to action tile"
description="A tile containing a full-size link, enclosing plain text"
add_permission="cmf.ModifyPortalContent"
schema=".tile.ICallToActionData"
class=".tile.CallToActionTile"
template="templates/calltoaction.pt"
permission="zope2.View"
for="*"
/>
这里是磁贴架构 class:
class ICallToActionData(IRichTextTileData):
target = RelationChoice(
title=_(u"Link target"),
description=_(u'Choose the item to which this button will link'),
source=UUIDSourceBinder(),
required=False,
)
link_text = Text(
title=_(u"Link button text"),
description=_(u"The text for the link button at the bottom"),
)
class CallToActionTile(RichTextTile):
def target_url(self):
url = None
if self.data['target']:
obj = uuidUtils.uuidToObject(self.data['target'])
if obj is not None:
if obj.portal_type == "Link":
site_url = getToolByName(obj, 'portal_url')()
if not obj.getRemoteUrl().startswith(site_url):
url = obj.getRemoteUrl()
else:
url = obj.absolute_url()
return url
def link_text(self):
return self.text_value('link_text')
- 克隆版 4.2.5
- plone.app.tiles 1.0.1
- plone.formwidget.contenttree 1.0.6
- plone.formwidget.autocomplete 1.2.4
问题的起因是这些重氮规则:
<drop css:content="body script" />
<after css:theme-children="html body" css:content="html body script" method="raw" />
如果 Diazo 主题处于活动状态,在调试问题时将其停用始终是个好主意。
我有一个带有 RelationChoice
字段的磁贴,但该字段只有静态 html 表单元素(一个 "nothing" 单选按钮、一个文本输入和一个 'Search' 按钮),它不会动态响应。在将它与另一个有效网站上的相同磁贴进行比较时,我注意到来自 plone.formwidget.contenttree 和 plone.formwidget.autocomplete 的特定于字段的 js 代码未嵌入磁贴源中。我在 https://github.com/plone/plone.formwidget.autocomplete/blob/master/plone/formwidget/autocomplete/widget.py#L142 and in https://github.com/plone/plone.formwidget.contenttree/blob/master/plone/formwidget/contenttree/widget.py#L253 中放置了断点,它们在磁贴加载时被击中,并且返回了正确的 js。但是不知道为什么发不给客户端
有什么想法吗?
磁贴上的其他一切正常,标准 jquery 资源已加载:
++resource++plone.formwidget.autocomplete/jquery.autocomplete.min.js
++resource++plone.formwidget.autocomplete/formwidget-autocomplete.js
++resource++plone.formwidget.contenttree/contenttree.js
这是我的图块的 zcml:
<plone:tile
name="peps.tiles.calltoaction"
title="PEPS call to action tile"
description="A tile containing a full-size link, enclosing plain text"
add_permission="cmf.ModifyPortalContent"
schema=".tile.ICallToActionData"
class=".tile.CallToActionTile"
template="templates/calltoaction.pt"
permission="zope2.View"
for="*"
/>
这里是磁贴架构 class:
class ICallToActionData(IRichTextTileData):
target = RelationChoice(
title=_(u"Link target"),
description=_(u'Choose the item to which this button will link'),
source=UUIDSourceBinder(),
required=False,
)
link_text = Text(
title=_(u"Link button text"),
description=_(u"The text for the link button at the bottom"),
)
class CallToActionTile(RichTextTile):
def target_url(self):
url = None
if self.data['target']:
obj = uuidUtils.uuidToObject(self.data['target'])
if obj is not None:
if obj.portal_type == "Link":
site_url = getToolByName(obj, 'portal_url')()
if not obj.getRemoteUrl().startswith(site_url):
url = obj.getRemoteUrl()
else:
url = obj.absolute_url()
return url
def link_text(self):
return self.text_value('link_text')
- 克隆版 4.2.5
- plone.app.tiles 1.0.1
- plone.formwidget.contenttree 1.0.6
- plone.formwidget.autocomplete 1.2.4
问题的起因是这些重氮规则:
<drop css:content="body script" />
<after css:theme-children="html body" css:content="html body script" method="raw" />
如果 Diazo 主题处于活动状态,在调试问题时将其停用始终是个好主意。