2

Using Solspace Freeform, I am trying to hardcode a radio gorup and its options in to a template. My effort is below but its not working

{# get the radio group field #}
{% set interestedIn = form.get("interestedIn") %}
{# Loop through the radio options #}                        
{% for option in interestedIn %}
<input type="radio" id="form-input-{{ interestedIn.handle }}" name="{{ interestedIn.handle }}" value="email">
<label for="form-input-{{ interestedIn.handle }}">Email</label>
{% endfor %}
0

To manually generate multi-option fields like radios, your code would look something like this:

{% set yourFieldHandle = form.get("yourFieldHandle") %}

<label>{{ yourFieldHandle.label }}</label>
{% for option in yourFieldHandle.options %}
   <div class="radio">
      <label>
         <input type="radio" name="yourFieldHandle" value="{{ option.value }}" {{ option.checked ? "checked" }} />
         {{ option.label|raw }}
      </label>
   </div>
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.