Skip to content

Commit 2287a6d

Browse files
committed
Fix traversing to widgets nested in an object widget
Fixes #29
1 parent 6071a9b commit 2287a6d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

news/29.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix traversing to widgets nested in an object widget [ale-rt]

src/plone/z3cform/traversal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from plone.z3cform.interfaces import IDeferSecurityCheck
55
from plone.z3cform.interfaces import IFormWrapper
66
from z3c.form import util
7+
from z3c.form.browser.object import ObjectWidget
78
from z3c.form.interfaces import IForm
89
from zope.component import adapter
910
from zope.interface import alsoProvides
@@ -86,6 +87,14 @@ def traverse(self, name, ignored):
8687
parts.remove("widgets")
8788
else:
8889
raise TraversalError("'" + part + "' not valid index")
90+
elif isinstance(target, ObjectWidget):
91+
# ObjectWidget is a special case, we need to look for
92+
# the name in the widget list
93+
name = parts.pop(0)
94+
try:
95+
target = target.widgets[name]
96+
except (IndexError, KeyError):
97+
target = None
8998
elif hasattr(target, "widgets"): # Either base form, or subform
9099
# Check to see if we can find a "Behaviour.widget"
91100
new_target = None

0 commit comments

Comments
 (0)