私は Plone の初心者であり、Dexterity で DataGridField を使用しようとしています。目標は、Plone 4.1 を使用してユーザビリティ調査の結果をイントラネットで公開することです。カスタム ドキュメント タイプ (インタラクションと呼ばれる) を作成しました。フィールドの 1 つにデータグリッドを使用して、調査結果の概要を示す 2 つの列を含むテーブルをモデル化したいと考えています。
collective.z3cform.datagridfieldにリストされている指示に従って、collective.z3cform.datagrid の卵をビルドアウトの卵のリストに正常に追加しました。新しいアドオンがアドオンのリストでアクティブとして表示されるのを確認できます。私のサイトのために。私が文書化しているユーザビリティ調査からの調査結果を示す文書を説明する単純なスキーマ Python モジュールを作成しました。
from five import grok
from zope import schema
from zope import interface
from plone.directives import form
from plonetheme.mytheme import InteractionMessageFactory as _
from plone.app.textfield import RichText
from z3c.form import field, button
from Products.CMFCore.interfaces import IFolderish
from collective.z3cform.datagridfield import DataGridFieldFactory, DictRow
class IFinding(interface.Interface):
summary = schema.TextLine(title=_(u"Summary"))
percentage = schema.TextLine(title=_(u"Percentage"))
class IInteraction(form.Schema):
findings = schema.List(
title=_(u"Overview of findings"),
required=False,
value_type=DictRow(
title=_(u"Finding"),
schema=IFinding
)
)
class EditForm(form.EditForm):
grok.context(IInteraction)
grok.require('zope2.View')
fields = field.Fields(IInteraction)
fields['findings'].widgetFactory = DataGridFieldFactory
profile/default/types.xml に次の行を追加して、新しい Interaction コンテンツ タイプを登録しました。
<?xml version="1.0"?>
<object meta_type="Plone Types Tool" name="portal_types">
<property name="title">Controls the available content types in your portal</property>
<object meta_type="Dexterity FTI" name="interaction" />
<!-- -*- extra stuff goes here -*- -->
</object>
完全を期すために、対応する profile/default/types/interaction.xml ファイルも含めました。
<?xml version="1.0"?>
<object name="interaction" meta_type="Dexterity FTI"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title">Interaction</property>
<property name="description">An item in the interactions dictionary</property>
<property name="icon_expr">string:${portal_url}/document_icon.png</property>
<property name="factory">interaction</property>
<property name="link_target"></property>
<property name="immediate_view">view</property>
<property name="global_allow">True</property>
<property name="filter_content_types">True</property>
<property name="allowed_content_types"/>
<property name="allow_discussion">False</property>
<property name="default_view">view</property>
<property name="view_methods">
<element value="view"/>
</property>
<property name="default_view_fallback">False</property>
<property name="add_permission">cmf.AddPortalContent</property>
<property name="klass">plone.dexterity.content.Item</property>
<property name="behaviors">
<element value="plone.app.dexterity.behaviors.metadata.IDublinCore"/>
<element value="plone.app.content.interfaces.INameFromTitle"/>
<element value="collective.flowplayer.behaviors.IFlowplayerFile"/>
</property>
<property name="schema">plonetheme.mytheme.interaction.IInteraction</property>
<property name="model_file"></property>
<alias from="(Default)" to="(dynamic view)"/>
<alias from="edit" to="@@edit"/>
<alias from="sharing" to="@@sharing"/>
<alias from="view" to="(selected layout)"/>
<action title="View" action_id="view" category="object" condition_expr=""
icon_expr="" link_target="" url_expr="string:${object_url}"
visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
icon_expr="" link_target="" url_expr="string:${object_url}/edit"
visible="True">
<permission value="Modify portal content"/>
</action>
</object>
Interaction カスタム タイプの Add フォームに移動すると、collective.z3cform.datagrid_demo の例で見たデータグリッド テーブル ウィジェットではなく、標準の Dexterity List アイテム Add/Remove ウィジェットが表示されます。カスタム タイプを保存しようとすると、器用さリスト ウィジェットに「システムは指定された値を処理できませんでした」という検証エラーが表示されます。
他に追加する必要があるコードはありますか? Dexterity Add/EditForm ビュー テンプレートをオーバーライドする必要がありますか?