I'm building a Guest Entry Form, and one of the fields is a dropdown. Everything feeds through fine, but if one of the other fields has a validation error, I can save any inputted data with the code as outlined in the Entry Form
<input id="customField" type="text" name="fields[customField]"
{%- if entry is defined %} value="{{ entry.customField }}"{% endif -%}>
But, with the dropdown, I can't get the value to stick, it always defaults to the first option (It's to grab a name title - eg, Mr. Mrs, Miss etc) on an error:
<select name="fields[honorific]">
{% for honortitle in entry.honorific.options %}
<option {%- if entry is defined %} value="{{ honortitle.value }}{% endif -%}">{% if entry is defined %}{{ honortitle.value }}</option>
{% endfor %}
</select>
So, if I've already selected the option at the bottom of the list, how do I get the field to remember what I've selected if there's an error elsewhere?
Thanks, Simon