<fieldset class="form-group">
<legend>Avez-vous déjà un compte utilisateur ?</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="exampleYes" name="example">
<label class="form-check-label" for="exampleYes">
Oui
</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="exampleNo" name="example">
<label class="form-check-label" for="exampleNo">
Non
</label>
</div>
</fieldset>
{%- if validation.class === 'danger' %}<div class="vd-form-group-{{ validation.class }}">{% endif %}
<fieldset class="form-group{% if styleModifier %} {{ styleModifier }}{% endif %}"
{% if helpText or validation.text -%}
aria-describedby="
{%- if helpText %}{{ id }}Help{% endif %}
{%- if validation.text %} {{id}}ErrorMessage{% endif -%}
"
{%- endif -%}>
<legend{% if legendModifier %} class="{{ legendModifier }}"{% endif %}>{{ legend }}</legend>
{%- if validation.text %}<div id="{{ id }}ErrorMessage"class="form-control-feedback text-{{ validation.class }}"><span class="sr-only">Erreur: </span>{{ validation.text }}</div>{% endif %}
{% if helpText -%}
<small
id="{{ id }}Help"
class="form-text text-secondary">{{ helpText }}</small>
{% endif %}
{% for item in items -%}
{% if not type or type === 'radio' %}
{% render '@radio', item %}
{% else %}
{% render '@checkbox', item %}
{% endif %}
{% endfor -%}
</fieldset>
{% if error %}</div>{% endif -%}
{
"id": "fieldset",
"legend": "Avez-vous déjà un compte utilisateur ?",
"items": [
{
"label": "Oui",
"name": "example",
"id": "exampleYes",
"styleModifier": "form-check-inline"
},
{
"label": "Non",
"name": "example",
"id": "exampleNo",
"styleModifier": "form-check-inline"
}
]
}
<fieldset>
Bearing in mind that <fieldset>
s are pointless without <legend>
s, you can use the following three rules of thumb to decide if a <fieldset>
is appropriate.
<fieldset>
s. No? Don’t use <fieldset>
s.<fieldset>.
No? Use a <fieldset>
if (1) applies.<legend>
that would make sense or aid comprehension if used with each of the <fieldset>
’s field labels? Yes? Use a <fieldset>
. No? Don’t use a <fieldset>
.<legend>
<form role="form" class="sorter" method="get">
<fieldset class="form-group"
>
<legend>Sort by</legend>
<div class="form-check">
<input class="form-check-input"
type="radio" value="most-recent" name="sort-method" checked >
<label class="form-check-label" for="">
most
recent
</label>
</div>
<div class="form-check">
<input class="form-check-input"
type="radio" value="popularity" name="sort-method" >
<label class="form-check-label" for="">
popularity
</label>
</div>
</fieldset>
<submit class="btn btn-success">Transmettre</submit>
</form>
The <form>
contains a single <fieldset>
which is used to group the radio options under the label “Sort by”, followed by a submit button. When a radio <input>
is focused, the <legend>
content is announced followed by the <input>
’s <label>
. To begin with, the first option (“most recent”) is checked. Standard behavior is that only this checked <input>
is focusable by Tab. Focusing it would trigger the announcement of “Sort by most recent, selected, radio button, one of four.” “Sort by” is the group label; “most recent” is the element label; “selected” is the element state; “radio button” is the element role. The number four is the total number of radio buttons which share a common name="sort-method
“.