Answers.Body: <p>The best way to debug a form field using custom HTML is to output the field you want via the default <code>displayForm</code> tag and copy the code from there as a starting point:</p>
  
  <pre><code>{# Output your checkboxes field here and look at the code generated #}
  {{ craft.sproutForms.displayForm('yourFormWithACheckbox') }}
  </code></pre>
  
  <p>Test with the default code that is output as your custom HTML and if that works, adjust from there.</p>
  
  <p>In general, we recommend using custom HTML with caution as it can increase the complexity of the code on the front-end a great deal.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-07T12:30:46.370Z
Answers.LastActivityDate: 2018-06-07T12:30:46.370Z
Answers.UserDisplayName: Ben Parizek
Body: <p>I have a form with a checkbox field. I want the options of the checkbox to be pulled from an entry field.</p>
  
  <p>My custom field template is below but it wont pass validation. I guess this is because Sprout looks for the option values to validate but as they are populated from an entry it wont pass??</p>
  
  <p>At the moment the example below is successfully displaying the entry data as options in the checkbox, it just wont allow me to submit the form.</p>
  
  <pre><code>{% if handle == "checkboxes1" %}
  
          &lt;div
                  {%- if id %} id="{{ id }}"{% endif %}
                  {%- if class %} class="{{ class }}"{% endif %}&gt;
  
              {% if name is defined and (name|length &lt; 3 or name|slice(-2) != '[]') %}
                  &lt;input type="hidden" aria-hidden="true" name="{{ name }}" value=""&gt;
              {% endif %}             
  
                  {% for date in entry.eventOccurrences %}                            
  
                  &lt;label for="checkboxes1-{{ loop.index }}"&gt;
  
  
                          &lt;input type="checkbox"
                          data-value="{{ date.date }}"
                                  {%- if name %} name="checkboxes1"{% endif %}
                                  {%- if id %} id="checkboxes1-{{ loop.index }}"{% endif %}
                                  {%- if value %} value="value-{{ loop.index }}"{% endif %}
                          &gt;
  
                          &amp;nbsp;{{ date.date }}||
  
                  &lt;/label&gt;
  
              {% endfor %}
          &lt;/div&gt;
  
  {% endif %}
  </code></pre>
  
Tags: <plugin-sproutforms><checkboxes>
Title: Sprout Forms: Populate checkbox field options with entry data
ThreadText: # Sprout Forms: Populate checkbox field options with entry data
  
  (Asked by: username_0 on 2018-06-06)
  
  I have a form with a checkbox field. I want the options of the checkbox to be pulled from an entry field.
  
  My custom field template is below but it wont pass validation. I guess this is because Sprout looks for the option values to validate but as they are populated from an entry it wont pass??
  
  At the moment the example below is successfully displaying the entry data as options in the checkbox, it just wont allow me to submit the form.
  
  ```
  {% if handle == "checkboxes1" %}
  
          <div
                  {%- if id %} id="{{ id }}"{% endif %}
                  {%- if class %} class="{{ class }}"{% endif %}>
  
              {% if name is defined and (name|length < 3 or name|slice(-2) != '[]') %}
                  <input type="hidden" aria-hidden="true" name="{{ name }}" value="">
              {% endif %}             
  
                  {% for date in entry.eventOccurrences %}                            
  
                  <label for="checkboxes1-{{ loop.index }}">
  
                          <input type="checkbox"
                          data-value="{{ date.date }}"
                                  {%- if name %} name="checkboxes1"{% endif %}
                                  {%- if id %} id="checkboxes1-{{ loop.index }}"{% endif %}
                                  {%- if value %} value="value-{{ loop.index }}"{% endif %}
                          >
  
                          &nbsp;{{ date.date }}||
  
                  </label>
  
              {% endfor %}
          </div>
  
  {% endif %}
  
  ```
  
  **Tags:** plugin-sproutforms, checkboxes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-07. Score: 1
  
  The best way to debug a form field using custom HTML is to output the field you want via the default `displayForm` tag and copy the code from there as a starting point:
  
  ```
  {# Output your checkboxes field here and look at the code generated #}
  {{ craft.sproutForms.displayForm('yourFormWithACheckbox') }}
  
  ```
  
  Test with the default code that is output as your custom HTML and if that works, adjust from there.
  
  In general, we recommend using custom HTML with caution as it can increase the complexity of the code on the front-end a great deal.
  
  
  ---
  
  