Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure if this counts as an answer <em>per se</em> but I ended up avoiding the need for a custom widget by creating custom Source &amp; SourceBinder objects.</p> <pre><code>class CTCCSource(object): implements(IVocabularyTokenized) container = None content_type = None def __init__(self, context): self.context = context container_path = self._container_path(context) self.catalog = getToolByName(context, 'portal_catalog') self.intid_utility = getUtility(IIntIds) self.content = [i.getObject() for i in self.catalog(portal_type=self.content_type, path={'query': container_path})] def _container_path(self, context): physical_path = list(context.getPhysicalPath()) trial_path = physical_path[:physical_path.index('sites')] criteria_path = trial_path + [self.container] return '/'.join(criteria_path) def __contains__(self, term): return term in self.content def __iter__(self): for crit in self.content: yield SimpleTerm(crit, self.intid_utility.getId(crit), crit.Title) def __len__(self): return len(self.content) def getTerm(self, obj): return SimpleVocabulary.createTerm( obj, self.intid_utility.getId(obj), obj.Title() ) def getTermByToken(self, value): return self.getTerm(self.intid_utility.getObject(int(value))) class CTCCSourceBinder(object): implements(IContextSourceBinder) source = None def __init__(self, **kw): pass def __call__(self, context): return self.source(context) </code></pre> <p>This allowed me to produce form checkbox fields from content contained within the current context, adding references to the chosen options into a RelatedList.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload