Hello,
I would like to make a multiple choice form with radio buttons, but I want to have optional text fields inside the radio text. Is there a simple way to do this in Grav?
Thanks,
Alex.
Hello,
I would like to make a multiple choice form with radio buttons, but I want to have optional text fields inside the radio text. Is there a simple way to do this in Grav?
Thanks,
Alex.
You can do anything that regular HTML can do with Grav. What exactly would the form look like in regular HTML?
Something like this
— html
eg:
-
type: radio
label: 'Label '
name: choice1
text: 'Bla bla bla...'
value: Choice
classes: radio-input
conclusion in a template:
{% if field.text %}
<p class="custom-class">{{ field.text }}
</p>
{% endif %}
or:
<input type="radio"
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|e('html_attr')|join(', ') }}"
{# input attribute structures #}
{% block input_attributes %}
{% if field.classes is defined %}class={{ field.classes }}" {% endif %}
{% if field.id is defined %}id="{{ field.id|e }}" {% endif %}
{% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
{% if field.disabled %}disabled="disabled"{% endif %}
{% if field.placeholder %}placeholder="{{ field.placeholder }}"{% endif %}
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
{% if field.validate.message %}title="{{ field.validate.message|e|t }}"
{% elseif field.title is defined %}title="{{ field.title|e|t }}" {% endif %}
{% endblock %}
/>
<label for="{% if field.id is defined %},{{ field.id|e }},{% else %},{{ field.name|e }},{% endif %}" class="">{{ field.label }}
</label>
---