docs(ds-toggle): warn against external hidden_field_tag with same name (#1925)

DS::Toggle already renders a paired hidden field for the off-state
value. Adding an external `hidden_field_tag` with the same `name` in a
caller view causes ID/label collisions (the auto-generated id matches
the checkbox id, so `<label for=...>` targets the hidden field) and
sends duplicate params.

Inline ERB comment so the warning surfaces wherever the component is
read or copied.
This commit is contained in:
Guillem Arias Fauste
2026-05-23 08:53:56 +02:00
committed by GitHub
parent 2ce8e858b6
commit 4bb326fee5

View File

@@ -1,4 +1,5 @@
<div class="relative inline-block select-none">
<%# Paired hidden field carries the off-state value when the checkbox is unchecked. Do NOT add an external `hidden_field_tag` with the same `name` in the caller view — it causes ID/label collisions and duplicate params. %>
<%= hidden_field_tag name, unchecked_value, id: nil %>
<%# `role="switch"` upgrades the underlying checkbox so AT users hear
"switch, on" / "switch, off" instead of "checkbox, checked". The