From 688d12f783c364d04fc29e60e724ac8881134598 Mon Sep 17 00:00:00 2001 From: Adam Groszer Date: Thu, 25 Feb 2016 02:11:50 +0100 Subject: [PATCH] Bugfix: The ``ChoiceTerms`` adapter blindly assumed that the passed in field is unbound, which is not necessarily the case in interesting ObjectWidget scenarios. Not it checks for a non-None field context first. [srichter] --- CHANGES.txt | 3 +++ src/z3c/form/term.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index eeb234d2..0325bbea 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,9 @@ CHANGES - CheckBoxWidget items are better determined when they are needed [agroszer] +- Bugfix: The ``ChoiceTerms`` adapter blindly assumed that the passed in field + is unbound, which is not necessarily the case in interesting ObjectWidget + scenarios. Not it checks for a non-None field context first. [srichter] 3.2.9 (2016-02-01) ------------------ diff --git a/src/z3c/form/term.py b/src/z3c/form/term.py index baa5d3da..780988bc 100644 --- a/src/z3c/form/term.py +++ b/src/z3c/form/term.py @@ -101,7 +101,8 @@ def __contains__(self, value): zope.schema.interfaces.IChoice, interfaces.IWidget) def ChoiceTerms(context, request, form, field, widget): - field = field.bind(context) + if field.context is None: + field = field.bind(context) terms = field.vocabulary return zope.component.queryMultiAdapter( (context, request, form, field, terms, widget),