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
This error also involves plone.app.relationfield, please advise if I should file an issue there as well or in lieu of this one.
When using StaticCatalogVocabulary with a RelationList/Choice and the StaticCatalogVocabulary, "add" forms work as expected but "edit" forms do not, when there is an existing value assigned to the context's field.
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.autoform import directives as form
from plone.app.z3cform.widgets.select import AjaxSelectFieldWidget
from plone.autoform.interfaces import IFormFieldProvider
from plone.base import PloneMessageFactory as _
from plone.supermodel import model
from plone.supermodel.directives import fieldset
from z3c.relationfield.schema import RelationChoice
from z3c.relationfield.schema import RelationList
from zope.interface import provider
from plone.app.vocabularies.catalog import StaticCatalogVocabulary
@provider(IFormFieldProvider)
class IRelatedItems(model.Schema):
"""Behavior interface to make a Dexterity type support related items."""
relatedItems = RelationList(
title=_("label_related_items", default="Related Items"),
default=[],
value_type=RelationChoice(
title="Related",
vocabulary=StaticCatalogVocabulary(
{
"review_state": "published",
},
title_template="{brain.Type}: {brain.Title} at {path}", # Custom item rendering!
)
#vocabulary="plone.app.vocabularies.Catalog"
),
required=False,
)
form.widget(
"relatedItems",
AjaxSelectFieldWidget,
pattern_options={ # Some options for Select2
"ajax": {"quietMillis": 500}, # Wait 500ms after typing to make query
},
)
# form.widget(
# "relatedItems",
# RelatedItemsFieldWidget,
# vocabulary="plone.app.vocabularies.Catalog",
# pattern_options={
# "recentlyUsed": True # Just turn on. Config in plone.app.widgets.
# },
# )
fieldset("categorization", label=_("Categorization"), fields=["relatedItems"])
To reproduce:
Create a Page (page1) and publish
Create another Page (page2) and in the related items field select page1. Save.
Edit page2
The text was updated successfully, but these errors were encountered:
This error also involves plone.app.relationfield, please advise if I should file an issue there as well or in lieu of this one.
When using StaticCatalogVocabulary with a RelationList/Choice and the StaticCatalogVocabulary, "add" forms work as expected but "edit" forms do not, when there is an existing value assigned to the context's field.
As a proof of concept I edited plone.app.relationfield.behavior to use the example from the docs https://6.docs.plone.org/backend/relations.html?highlight=staticcatalogvocabulary#using-different-widgets-for-relations almost verbatim.
To reproduce:
The text was updated successfully, but these errors were encountered: