When custom forms include a choice column (previously known as an optionset or a picklist), access to the metadata is required to include all possible values as part of the markup, usually as a SELECT
HTML tag.
Dataverse plugin includes global metadata
object which is an array of entity metadata objects indexed by the table name. This objects include attribute metadata including localized labels for all choice column values. For example, the following twig fragment creates a SELECT
tag for Gender column using labels in the default language.
<select>
{% for optionMeta in metadata['contact'].Attributes['gendercode'].OptionSet.Options %}
<option value="{{ optionMeta.Value }}">
{{ optionMeta.Label.UserLocalizedLabel.Label }}
</option>
{% endfor %}
</select>
In this example metadata['contact'].Attributes['gendercode']
is a n OptionSetMetadata object and twig has full access to its properties.