【问题标题】:Dexterity reorder inherited fields敏捷重新排序继承的字段
【发布时间】:2013-06-10 11:31:38
【问题描述】:

如何对从我自己编写的字段定义中的现有行为继承的字段重新排序。 例如,我想使用 plone.app.contenttypes 中的 Leadimage 字段(行为),但我不想将它放在我定义的所有字段的底部,而是希望在描述之后使用它。

我试过这样:

<property name="model_source">
    &lt;model xmlns:security="http://namespaces.plone.org/supermodel/security" 
          xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" 
          xmlns:form="http://namespaces.plone.org/supermodel/form" 
          xmlns="http://namespaces.plone.org/supermodel/schema"&gt;
    &lt;schema&gt;
      &lt;field name="image" type="plone.namedfile.field.NamedBlobImage" form:after="description"&gt;
          &lt;title&gt;Image&lt;/title&gt;
      &lt;/field&gt;
    &lt;/schema&gt;
    &lt;/model&gt;
</property>

顺便说一句。有没有更易读的方法来做到这一点?

【问题讨论】:

    标签: plone dexterity


    【解决方案1】:
    form.order_after(image1='ILeadImage.image')
    

    成功了,在代码示例中有点混乱......

    后续问题: 如果我有 3 个图像字段,每个字段都有一个标题字段,我真的必须将该行添加到每个字段本身吗?或者有没有办法像字段集定义一样在一个地方设置所有字段的顺序?

    【讨论】:

      【解决方案2】:

      我从未尝试过使用 XML,但 Dexterity XML 文档说这是可能的;检查 after/before 属性。

      我认为您可以使用 Python 代码进行更多控制;查看Form schema hints 文档。

      【讨论】:

      • thanx,反正我更喜欢 python 方式;)
      猜你喜欢
      • 1970-01-01
      • 2018-08-23
      • 2012-10-05
      • 1970-01-01
      • 2017-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多