Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In select widget, accept items as property or method. #49

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ New features:

Bug fixes:

- *add item here*
- In select widget, accept items as property or method.
This avoids breaking on some z3c.form versions.
See https://github.com/zopefoundation/z3c.form/issues/44
[maurits]


2.1.1 (2016-09-16)
Expand Down Expand Up @@ -75,7 +78,7 @@ Fixes:
- Reduce dependency on plone.app.widgets in tests.
[thet]

- Enhance test in order to show problem in RelatedItemsWidget with
- Enhance test in order to show problem in RelatedItemsWidget with
navigation-roots
[jensens]

Expand Down
10 changes: 9 additions & 1 deletion plone/app/z3cform/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,16 @@ def _base_args(self):
if not self.required:
options['allowClear'] = True

base_items = self.items
if callable(base_items):
# items used to be a property in all widgets, then in the select
# widget it became a method, then in a few others too, but never in
# all, so this was reverted to let it be a property again. Let's
# support both here to avoid breaking on some z3c.form versions.
# See https://github.com/zopefoundation/z3c.form/issues/44
base_items = base_items()
items = []
for item in self.items():
for item in base_items:
if not isinstance(item['content'], basestring):
item['content'] = translate(
item['content'],
Expand Down