From 42015acda261295282dbd82b4ca0bee18ae4ba5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Birkemeyer?= Date: Fri, 21 Jun 2019 11:10:01 +0000 Subject: [PATCH] Hide the HoneypotField from assistive technology (AT) Users of AT (e.g. screen readers) navigate with arrow keys which do not (always) respect tabindex=-1, so the additional ARIA attribute is necessary. --- Form/Type/HoneypotType.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Form/Type/HoneypotType.php b/Form/Type/HoneypotType.php index 3ad1da2..6b771b8 100644 --- a/Form/Type/HoneypotType.php +++ b/Form/Type/HoneypotType.php @@ -99,9 +99,12 @@ public function configureOptions(OptionsResolver $resolver) 'mapped' => false, 'data' => '', 'attr' => array( - //autocomplete="off" does not work in some cases, random strings always do + // autocomplete="off" does not work in some cases, random strings always do 'autocomplete' => 'nope', + // Make the field unfocusable for keyboard users 'tabindex' => -1, + // Hide the field from assistive technology like screen readers + 'aria-hidden' => 'true', // Fake `display:none` css behaviour to hide input // as some bots may also check inputs visibility 'style' => 'position: fixed; left: -100%; top: -100%;'