2012-01-11 29 views
0

我已将collective.z3cform.datagridfield添加到我的构建中,请将其视为在我的网站设置中处于活动状态;但是,我无法通过透明网页编辑器为灵巧内容类型添加datagridfield类型的字段。我错过了什么?datagridfield在通过web内容类型编辑器的敏捷中不可见

+1

TTW编辑器不会自动支持这些附加字段。该领域需要与plone.schemaeditor进行一点整合。 – vangheem 2012-01-13 18:17:30

+0

如果你能指出我将它与plone.schemaeditor集成的正确方向,你可能会赢得一个答案。或者如果你只是发布了一个答案,而不是一个评论,并提供更多关于你如何学习的信息。没有理由让你不要因为帮助而获得业力。 – FMM 2012-01-13 22:50:49

回答

2

扩展vangheem的答案:你可以通过提供一个字段工厂来为collective.z3cform.datagridfield提供支持,但它会是一种破解。

原因是,collective.z3cform.datagridfield.row.DictRow需要定义表格行的模式。这成为一旦呈现的子表单。此实例中的模式编辑器需要根据(表格)模式的字段类型来询问您。

取决于你是什么解决方案之后,你也许能够通过实现与固定表架构场厂这样就完事了:

from five import grok 
from zope import schema 
import collective.z3cform.datagridfield.row 
import plone.schemaeditor.interfaces 
import zope.interface 

# example from http://pypi.python.org/pypi/collective.z3cform.datagridfield 
class ITableRowSchema(zope.interface.Interface): 
    one = schema.TextLine(title=u"One") 
    two = schema.TextLine(title=u"Two") 
    three = schema.TextLine(title=u"Three") 

# new field factory for the zope.schema.interfaces.IObject 
class DataGridFieldFactory(grok.GlobalUtility): 
    grok.provides(plone.schemaeditor.interfaces.IFieldFactory) 
    # this will show up in the schema editor vocabulary 
    title = "DataGridField" 

    def __call__(self, *args, **kwargs): 
     # that's the horrid part as it will nail your field to this 
     # specific schema 
     kw = dict(value_type=collective.z3cform.datagridfield.row.DictRow(
      schema=ITableRowSchema)) 
     kwargs.update(kw) 
     return zope.schema.List(*args, **kwargs) 

请看看到:plone.schemaeditor.fields.py更多有关现场工厂的信息。

这将为您提供一个基本的数据网格,供您的内容类型使用。缺少的是小部件,目前您无法声明AFAIK。

+0

因此,如果我正确地理解了你,TTW类型编辑器无法处理它,因为定义DGF的模式作为定义内容类型模式的子流程变得麻烦。它是否正确? – FMM 2012-01-20 03:32:12

+0

是的,这是正确的。根据我的理解,你所追求的目前不被支持。但是,根据你的情况和软件的可能性(由我的例子给出),你可能会得到一个半解决方案。 – romanofski 2012-01-21 08:39:13

相关问题