...
<option value="">Select</option>
{% for option in states %}
<option val="{{ option.value }}"
{%- if account is defined and option.label in account.address.state %} selected {% endif -%}>
{{ option.label }}
</option>
{% endfor %}
...
<option value="">Select</option>
{% for option in myField %}
<option val="{{ option.value }}"
{%- if account is defined and option.label in account.myField.label %} selected {% endif -%}>
{{ option.label }}
</option>
{% endfor %}
I think it's also worth noting that by setting myField
as a required field in the CP, I needed to hard-code the <option value="">Select</option>
in the template rather than putting it as a field value. When I had it as a field value, I (think) Craft was accepting that as a selected value and I was not getting the error message.