In control panel (Plone 6.0.5), I have a List with an InOutWidget.
If I just add items to 'In', I can not save (see screenshot: Error is 'choose an object in the list').
If I click on any item, I can save.
Any idea how to troubleshoot / fix this?
In control panel (Plone 6.0.5), I have a List with an InOutWidget.
If I just add items to 'In', I can not save (see screenshot: Error is 'choose an object in the list').
If I click on any item, I can save.
Any idea how to troubleshoot / fix this?
There is a closed PR on plone.app.z3cform OrderedSelectWidget: preselect the saved values to fix browser validation of required input by petschki · Pull Request #178 · plone/plone.app.z3cform · GitHub
Thanks (I could not figure out that its name is 'OrderedSelectWidget', kept searching for 'InOutWidget' )
The OrderedSelectWidget widget is missing from the list of fields included in Plone: 20. Dexterity: Reference – Mastering Plone 6 Development — Plone Training 2023 documentation
I need to set 'the order of the fields', is there another way of doing this.
(In my control panel, I choose which fields (and in which order) should render in my 'table-view')
UPDATE: Maybe using DataGridField with ChoiceField could be an option.
Example below is from a Plone 5.2 site. This approach does not work anymore?
# -*- coding: UTF-8 -*-
from plone.app.registry.browser import controlpanel
from Products.CMFPlone import PloneMessageFactory as _
from zope import schema
from zope.interface import implementer
from zope.interface import Interface
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleVocabulary
from zope.component import queryUtility
from plone.registry.interfaces import IRegistry
@implementer(IVocabularyFactory)
class ImageScalesVocabulary(object):
def __call__(self, context):
registry_key = 'collective.behavior.dryslider.browser.controlpanel.IDRYSliderSettings.image_scales'
registry = queryUtility(IRegistry)
terms = []
if registry is not None:
for image_scale in registry.get(registry_key, ()):
# create a term - the arguments are the value, the token, and
# the title (optional)
terms.append(SimpleVocabulary.createTerm(image_scale, image_scale, image_scale))
return SimpleVocabulary(terms)
class IDRYSliderSettings(Interface):
types = schema.List(
title=u'Types',
description=_(u'Types displaying inherited banners'),
required=False,
value_type=schema.Choice(
vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes',
),
default=[
'Collection',
'Document',
'Event',
'File',
'Folder',
'Link',
'News Item'
]
)
image_scales = schema.List(
title=_(u'Slider scales'),
description=_(u'Scales at which slider images can be displayed'),
required=True,
value_type=schema.Choice(vocabulary='plone.app.vocabularies.ImagesScales',
default=[
'slider_full_height',
]
)
)
class DRYSliderSettingsEditForm(controlpanel.RegistryEditForm):
schema = IDRYSliderSettings
label = _(u'Slider settings')
description = _(u'')
def updateFields(self):
super(DRYSliderSettingsEditForm, self).updateFields()
def updateWidgets(self):
super(DRYSliderSettingsEditForm, self).updateWidgets()
class DRYSliderControlPanel(controlpanel.ControlPanelFormWrapper):
form = DRYSliderSettingsEditForm
No, there is an issue with inline validation, read answer from Jan
For reference: That aproach works, but you need to use another (not the default) widget for the choice field:
class ITableRows(model.Schema):
row_title = schema.TextLine(
title=_(u'Table title', 'Table title'),
required=False,
)
widget(row_field=SelectFieldWidget)
row_field = schema.Choice(
vocabulary=u"MyAddon.ActionItems.AiFieldsVocabulary",
title=_(u"Field", default=u"Field"),
required=False,
)
widget(table_columns=DataGridFieldFactory)
table_columns = schema.List(
title = _(u"Table Columns",
default=u"Table Column fields"),
value_type=DictRow(schema=ITableRows),
)
PS: row_title can be skipped.