I'm a little new to Plone, and I'm trying to use DataGridField with dexterity. The goal is to use Plone 4.1 to publish usability research results on our intranet. I created my own type of document (called an interaction), and I want to use a datagrid for one of the fields to simulate a table containing two columns that contain a summary of the results.
According to the instructions listed in collective.z3cform.datagridfield, I have successfully added the collect.z3cform.datagrid egg to the list of eggs in my buildout, and I see that the new add-in appears as active in my add-on list for my site. I created a simple Python module for a schema that describes a document showing the results of a usability study that I am documenting:
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
I registered my new type of interaction content by adding a line to the /default/types.xml profiles:
<?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" /> </object>
For completeness, I also included the appropriate profiles / default / types / interactive.xml file:
<?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>
When I go to the "Add" form for my special type "Interaction", I get the standard Add / Remove element "Dexterity", and not the data table widget that I saw in the examples collect.z3cform.datagrid_demo. When I try to save a custom type, the Agility list widget displays a validation error. "The system could not process the setpoint."
Is there any other code I need to add? Do I need to override Dexterity Add / EditForm view templates?
Andrew Heckford
source share