In a customized Sprout Form field, is it possible to have radio buttons and checkboxes with a value
of other
have an additional text input in the label
? This text input would presumably need to be tied to a separate text field in Sprout Forms which would not render with the other normal plaintext fields.
Is there some way to create a custom field that would make it possible to add the boolean radio/checkbox and input together with something like a matrix? We have multiple "other" + text input fields on the page we're trying to create. No set of options
will ever have more than one other
option.
The resulting markup might look something like this:
{% if type == 'radiobuttons' %} {# Or 'mycustomradiobuttontype' #}
<ol>
{%- for key, option in options %}
{%- set label = (option.label is defined ? option.label : option) %}
{%- set value = (option.value is defined ? option.value : key) %}
{%- set checked = (value == selectedValue) %}
<li class="radio">
<input type="radio"
{%- if id %} id="{{ id }}-{{ loop.index }}"{% endif %}
{%- if name %} name="{{ name }}"{% endif %}
{%- if value %} value="{{ value }}"{% endif %}
{%- if checked is defined and checked %} checked{% endif %}
{{- dataAttributes -}}>
<label {%- if id %} for="{{ id }}-{{ loop.index }}"{% endif %}>
{%- if label is defined %}{{ label|raw }}{% endif -%}
{% if value == 'other' %}
<input type="text" name="TODO" value="TODO">
{% endif %}
</label>
</li>
{% endfor %}
</ol>
{% endif %}