Selection

A field of type Selection gives you either a dropdown-style or a table-style way of selecting one or more predefined values.

You can mark values to be suggested when editing a product, a page, etc. that doesn’t have a value for that field already. If you would like a default value of "Blue" to be suggested by default in a selection of "Red, Green, Blue", just prefix the option with a colon: ":Blue" in the field definition

You can opt to have selections use another value than the one presented in the ACF editor by separating the value and the presentation string with double colons - "value::string".

To have e.g. a color code stored for a selection of a named color, enter "#0000ff::Blue". This will show the option as "Blue" in the ACF editor dropdown but actually store the value "#0000ff" in the Metafield

The selection is represented as a Metafield with its string value matching the selected value:

<p>You have selected the value: {{ product.metafields.accentuate.selection }}</p>

Or, in case of multiple selected values, with each value listed using the "pipe" symbol ("|") as a separator token. You can use Liquid's 'split' filter on the Metafield to separate the values - like this:

{% assign selected_values = product.metafields.accentuate.selection | split: '|' %}

{% for selected_value in selected_values %} 
  <p>{{ selected_value }}</p> 
{% endfor %}

Last updated