Closed Arkusm closed 1 year ago
Confirmed
Preliminary investigation of the traceback:
Module collective.z3cform.datagridfield.datagridfield, line 283, in value
Module plone.app.z3cform.converters, line 361, in toWidgetValue
Module plone.app.z3cform.converters, line 362, in <listcomp>
value
is a UUID (as string). Expected: list of UUIDs
So the list comprehension iterates over the single chars of the UUID which explains the adapation error for single chars of the UUID.
As a workaround, I tried to converted value
into [value]
.
With this workaround, the IUUID
lookup fails for a correct (existing UUID).
I verified that by searching for the portal_catalog by the given UUID.
So obviously, a list of UUIDs get converted somewhere in the stack to a string (or even the UI sends improper data).
A modified version of the converter seems to work for us and possibly resolves the problem
def toWidgetValue(self, value):
"""Converts from field value to widget.
:param value: List of catalog brains.
:type value: list
:returns: List of of UID separated by separator defined on widget.
:rtype: string
"""
if not value:
return self.field.missing_value
separator = getattr(self.widget, "separator", ";")
if IRelationList.providedBy(self.field):
if isinstance(value, str):
value = [value]
return separator.join(v for v in value if v)
else:
return separator.join([IUUID(o) for o in value if o])
else:
return separator.join(v for v in value if v)
Confirmed. I've made a PR here https://github.com/collective/collective.z3cform.datagridfield/pull/142 ... turns out, that the context binding on the IChoice
columns was wrong ... with this fix it works for me.
One more update here #150
I've fixed the DictRowConverter
to correctly convert the columns to their schema field/widget values. This fixes several issues for me when using Choice
fields in the DictRow
schema.
@petschki I can confirm that your PR fixes the issue where the relation field is not working correctly š
Fixed by #150 š
Plone: classic 6.0.0b3 datagridfield branch: master
RelationList and RelatedItemsFieldWidget work great when I edit an object. I need the RelatedItemsFieldWidget because it is the only Widget that supports ordering selected items. But when I try to save there is an error:
schema.Choice works without RelationList. The error must come from RelationList/RelatedItemsFieldWidget.