You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the documentation in collective.z3cform.datagridfield is add/edit form oriented. What about a common integrator that want to add a DGF field in a content type?
What I've found it works (with widget parameters customization):
on the model (dexterity control panel "Edit XML Field Model" for example):
@adapter(schema.interfaces.IField, form.interfaces)@implementer(form.interfaces.IFieldWidget)defServiziDataGridFieldFactory(field, request):
""" A special widget constructor setting up widget parameters for DGF. """widget=DataGridFieldFactory(field, request)
widget.allow_reorder=Truereturnwidget
If you don't need widget customization, it is simpler:
on the model (dexterity control panel "Edit XML Field Model" for example):
What works but you cannot change widget defaults with hints:
xml schema:
<fieldname="servizi"type="zope.schema.List"> <!-- here you can put name="table", works the same =) -->
<description>...</description>
<title>Servizi</title>
<value_typetype="collective.z3cform.datagridfield.DictRow">
<schema>myproduct.interfaces.ITableRowSchema</schema>
</value_type>
<form:widgettype="collective.z3cform.datagridfield.datagridfield.DataGridFieldWidgetFactory" />
</field>
widget interfaces:
fromcollective.z3cform.datagridfield.datagridfieldimportDataGridFieldFactoryfromcollective.z3cform.datagridfield.rowimportDictRowfromplone.autoform.directivesimportwidgetfromplone.autoform.formimportAutoExtensibleFormfromz3c.formimportformfromzopeimportinterfacefromzopeimportschemaclassITableRowSchema(interface.Interface):
servizio=schema.TextLine(title=u"Servizio")
telefono=schema.TextLine(title=u"Telefono")
email=schema.TextLine(title=u"Email")
classIFormSchema(interface.Interface):
servizi=schema.TextLine(title=u"Servizi")
table=schema.List(
title=u"Servizi",
value_type=DictRow(
title=u"servicerow",
schema=ITableRowSchema,
),
)
widget("table", DataGridFieldFactory, allow_reorder=True,) # <- you can comment it, does nothing in my experience.
Note: here we have "servizi" + "table" but "it works". It works also if you change "table" in the xml schema above with "servizi", this is totally obscure to me, sorry my fault.
then you can install the demo package in the addons and you have the behavior registered for Document and a new DGFTest contenttype ... I'll come up with some more tests too.
Hi!
the documentation in collective.z3cform.datagridfield is add/edit form oriented. What about a common integrator that want to add a DGF field in a content type?
What I've found it works (with widget parameters customization):
ITableRowSchema:
and in widget.py:
If you don't need widget customization, it is simpler:
What works but you cannot change widget defaults with hints:
xml schema:
widget interfaces:
Note: here we have "servizi" + "table" but "it works". It works also if you change "table" in the xml schema above with "servizi", this is totally obscure to me, sorry my fault.
I'm aware it should work without behaviours (see: https://github.com/kombinat/collective.coursetool/blob/main/src/collective/coursetool/content/course.py#L57) but I still have to get it after several hours of reading and breakpoints (my fault).
Another missing piece (my opinion) is some hints on how to manage schemas (xml, profiles, object schema from model.schema).
The text was updated successfully, but these errors were encountered: