Skip to content

Commit

Permalink
fix issue with required choice-field without value by defining a defa…
Browse files Browse the repository at this point in the history
…ult-value
  • Loading branch information
pbauer committed Sep 27, 2024
1 parent 7999f13 commit 18ba005
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/plone/app/standardtiles/existingcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class IExistingContentTile(model.Schema):

view_template = schema.Choice(
title=_("Display mode"),
source=_("Available Content Views"),
source="Available Content Views",
required=True,
)

Expand Down Expand Up @@ -174,8 +174,10 @@ def content_view(self):
def content_view_name(self):
context = self.content_context
if context is not None:
view_name = self.data.get("view_template") or context.getLayout()
return view_name
if self.data.get("view_template") == "default_layout":
return context.getLayout()
else:
return self.data.get("view_template") or context.getLayout()
return ""

_marker = dict()
Expand Down Expand Up @@ -269,7 +271,9 @@ def availableContentViewsVocabulary(context):

registry = getUtility(IRegistry)
listing_views = registry.get("plone.app.standardtiles.content_views", {}) or {}
voc = [SimpleVocabulary.createTerm("", "", "Default view")]
voc = [
SimpleVocabulary.createTerm("default_layout", "default_layout", "Default view")
]
for key, label in sorted(listing_views.items(), key=itemgetter(1)):
voc.append(SimpleVocabulary.createTerm(key, key, label))
return SimpleVocabulary(voc)

0 comments on commit 18ba005

Please sign in to comment.