[collective.easyform] Overrides for vocabulary name or custom vocabulary provider method?

For a select/multi select field in EasyForm you can choose between a list of fixed value or a named vocabulary. This is not applicable in our case because the list of available values is computed based on some context information and based on the language. Is there a way for a vocabulary overrides expression somewhere?

do you mean something like that:

# vocabulary.zcml
<utility
  name="your-named-vocabulary"
  component=".vocabulary.your_vocabulary"
  provides="zope.schema.interfaces.IVocabularyFactory" />
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

# vocabulary.py
def your_vocabulary(context):
  terms=[]
  # ....
  # here calculate your vocabulary items
  # ....
  terms.append(SimpleTerm(option[1], token=idnormalizer.normalize(option[0]), title=option[2]))
  return SimpleVocabulary(terms)

ehm...yes, you're right. Thanks for slapping on my head :slight_smile:

it's hard times, no problem.

2 Likes