Skip to content

Commit

Permalink
Implement renderForValue on ContentTreeBase in order to make …
Browse files Browse the repository at this point in the history
…single valued relation fields work.
  • Loading branch information
rnixx committed Oct 20, 2014
1 parent 3467922 commit bf0f6cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/HISTORY.txt
Expand Up @@ -4,6 +4,10 @@ Changelog
1.0.8 (unreleased)
------------------

* Implement ``renderForValue`` on ``ContentTreeBase`` in order to make
single valued relation fields work.
[rnixx]

* Work around bizarro Diazo encoding bug
[gyst]

Expand Down
18 changes: 18 additions & 0 deletions plone/formwidget/contenttree/widget.py
Expand Up @@ -216,6 +216,24 @@ def render(self):
else:
return self.input_template(self)

def renderForValue(self, value):
try:
return super(ContentTreeBase, self).renderForValue(value)
except LookupError, e:
if value != z3c.form.widget.SequenceWidget.noValueToken:
raise e
item = {
'id': '%s-0' % self.id,
'name': self.name,
'value': '',
'checked': 'checked',
}
template = getMultiAdapter(
(self.context, self.request, self.form, self.field, self),
IPageTemplate, name=self.mode + '_single'
)
return template(self, item)

def js_extra(self):
# Get bound source to extract path
source = self.bound_source
Expand Down

0 comments on commit bf0f6cb

Please sign in to comment.