Dictionaries
Pro
A dictionary is a list of choices you manage in one place and use in any number of choice fields. A bookshop might keep one Formats dictionary and use it on Books, on Writers and on a user's "preferred format" field. Add "Hardcover" to the dictionary once, and every field that uses it offers the new choice.
Each entry has a label, which editors see, and a value, which is what gets stored. You can reword labels at any time; stored values stay put.
VX also ships read-only system dictionaries for countries, currencies and units of measurement.
A short list you'll only use once, like $, $$, $$$, can stay as choices typed into the field. Once you'd type a list twice, make it a dictionary.
Who can read a dictionary
Creating, editing, importing and exporting dictionaries, on the Dictionaries screen, is for administrators.
Reading a dictionary's entries goes with the fields that use it. Anyone who can fill in a field that takes its choices from a dictionary gets that dictionary's entries as the field's choices, and anyone who can fill in a Phone field gets the countries list for its country picker. An Author editing their own post picks a Format from the dictionary without being able to open the Dictionaries screen.
The entries are offered only where the field is. Someone who can't edit the post, term or profile, or whom a fieldset's Viewer role or Viewer capability condition leaves out, can't read a dictionary through that fieldset. See Where fields appear.
Technical details for LLMs
- Read routes (
vx-framework/v1):GET dictionaries/{key}/entries,GET dictionaries/{key}/lookup,GET system-dictionaries/{key}/entriesandGET system-dictionaries/{key}/lookupallowmanage_options, or a request that names a fieldset (fieldset) and the object being edited (entity_id, withobject=taxonomy|user|option_pagewhen it isn't a post; no id on an Add New screen). It passes when the user edits that fieldset on that object, the same check asfieldsets/{key}/sources/{field_key}(the object's own capability, Location conditions including viewer ones; on Add New, the capability to create an object the fieldset attaches to), and a field in the fieldset, nested ones included, reads that dictionary:choices_source: "dictionary"withdictionary: "{key}",choices_source: "system_dictionary"withsystem_dictionary: "{key}", or aphonefield for thecountriessystem dictionary. The field editor sends these parameters on every options request. - Every other dictionary route needs
manage_options:GET/POST dictionaries,dictionaries/validate-key,GET/DELETE dictionaries/{key},dictionaries/{key}/config,PUT dictionaries/{key}/entries,dictionaries/{key}/entries/changes,dictionaries/{key}/references,dictionaries/{key}/import,dictionaries/{key}/export,GET system-dictionariesandGET system-dictionaries/{key}.