<p>This feature has been added in <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/fields" rel="nofollow">Sprout Fields</a> v2.1.0</p>

<p>You can now use the Email Select field via custom HTML and obfuscate email addresses. I've added <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/fields/docs/overview/email-select-field" rel="nofollow">an example in the docs</a>:</p>

<pre><code>{% set contact = craft.sproutForms.form('contact') %}

{% set emailSelectField = contact.getField('emailSelect') %}

&lt;select name="fields[{{ emailSelectField.handle }}]"&gt;

  {% set value = contact is defined ? contact.emailSelect.value : null %}

  {% set options = craft.sproutFields.obfuscateEmailAddresses(emailSelectField.settings.options, value) %}

  {% for option in options %}

    {% if value != "" %}
      {% set selected = (option.selected == 1) ? true : false %}
    {% else %}
      {% set selected = (option.default == 1) ? true : false %}
    {% endif %}

    &lt;option value="{{ option.value }}" {% if selected %}selected{% endif %}&gt;{{ option.label }}&lt;/option&gt;

  {% endfor %}

&lt;/select&gt;
</code></pre>

CC BY-SA 4.0
2019-11-03T08:09:07.997Z
I've somehow put myself in a situation where I have to pass the $option index in for the value attribute. I used loop.index0. It's better in our case because our option.values aren't unique, but option.value didn't work for us.
ponies
CC BY-SA 3.0
2016-09-26T16:37:55.240Z
2016-09-26T16:37:55.240Z
Ben Parizek
<p>I'm trying to customize the markup of an email select field in Sprout Forms, however, when I customize the markup with <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/examples/custom-html" rel="nofollow">Custom HTML</a>, as specified in the documentation, it outputs the actual <code>value</code> rather than purging it to hide them from spam bots. I just need to know what I should include in the options to purge these. Here is the code I've been using.</p>

<pre><code>{% set recipient = form.getField('emailRecipient') %}  
&lt;select name="fields[{{ recipient.handle }}]"&gt;
  {% for option in recipient.settings.options %}
  &lt;option value="{{ option.value }}" {% if option.value == value.value %}selected{% endif %}&gt;{{ option.label }}&lt;/option&gt;
  {% endfor %}
&lt;/select&gt;
</code></pre>

<p>Any help would be greatly appreciated!</p>

<p>Thanks.</p>

CC BY-SA 3.0
2016-09-03T07:48:29.147Z
This is likely a bug. I've added it to our list to look into and will update this thread once it's fixed.
Ben Parizek
<templating><plugin-sproutforms>
Customize markup of email select field in Sprout Forms
# Customize markup of email select field in Sprout Forms

(Asked by: username_0 on 2016-08-14)

I'm trying to customize the markup of an email select field in Sprout Forms, however, when I customize the markup with Custom HTML, as specified in the documentation, it outputs the actual value rather than purging it to hide them from spam bots. I just need to know what I should include in the options to purge these. Here is the code I've been using.
{% set recipient = form.getField('emailRecipient') %}  

  {% for option in recipient.settings.options %}
  {{ option.label }}
  {% endfor %}


Any help would be greatly appreciated!
Thanks.

**Tags:** templating, plugin-sproutforms

> **Comments:**
> **username_1**: This is likely a bug. I've added it to our list to look into and will update this thread once it's fixed.  

---

## 1 answers

### Answer by username_1 on 2016-09-26. Score: 2

This feature has been added in Sprout Fields v2.1.0
You can now use the Email Select field via custom HTML and obfuscate email addresses. I've added an example in the docs:
{% set contact = craft.sproutForms.form('contact') %}

{% set emailSelectField = contact.getField('emailSelect') %}



  {% set value = contact is defined ? contact.emailSelect.value : null %}

  {% set options = craft.sproutFields.obfuscateEmailAddresses(emailSelectField.settings.options, value) %}

  {% for option in options %}

    {% if value != "" %}
      {% set selected = (option.selected == 1) ? true : false %}
    {% else %}
      {% set selected = (option.default == 1) ? true : false %}
    {% endif %}

    {{ option.label }}

  {% endfor %}

> **Comments:**
> **username_2**: I've somehow put myself in a situation where I have to pass the $option index in for the value attribute. I used loop.index0. It's better in our case because our option.values aren't unique, but option.value didn't work for us.  

---

