From fd24a6139afc1ead15e855eeb338f5c9f28ac0a2 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Mon, 3 Jan 2022 17:39:03 +0000 Subject: [PATCH] Improve accessibility - associate label and fields --- CRM/Contact/Form/Edit/Email.php | 6 +++++- CRM/Contact/Form/Edit/Phone.php | 13 +++++++++++-- templates/CRM/Contact/Form/Edit/Phone.tpl | 2 +- templates/CRM/Contact/Form/Inline/Phone.tpl | 2 +- templates/CRM/Event/Form/ManageEvent/Location.tpl | 12 ++++++------ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CRM/Contact/Form/Edit/Email.php b/CRM/Contact/Form/Edit/Email.php index f6c1a3cbec..fb073da005 100644 --- a/CRM/Contact/Form/Edit/Email.php +++ b/CRM/Contact/Form/Edit/Email.php @@ -42,7 +42,11 @@ class CRM_Contact_Form_Edit_Email { $form->applyFilter('__ALL__', 'trim'); //Email box - $form->addField("email[$blockId][email]", ['entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId])]); + $form->addField("email[$blockId][email]", [ + 'entity' => 'email', + 'aria-label' => ts('Email %1', [1 => $blockId]), + 'label' => ts('Email %1', [1 => $blockId]), + ]); $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType) || $blockEdit) { //Block type diff --git a/CRM/Contact/Form/Edit/Phone.php b/CRM/Contact/Form/Edit/Phone.php index 251829acf1..9d652f1d8e 100644 --- a/CRM/Contact/Form/Edit/Phone.php +++ b/CRM/Contact/Form/Edit/Phone.php @@ -48,8 +48,17 @@ class CRM_Contact_Form_Edit_Phone { 'placeholder' => NULL, ]); //main phone number with crm_phone class - $form->addField("phone[$blockId][phone]", ['entity' => 'phone', 'class' => 'crm_phone twelve', 'aria-label' => ts('Phone %1', [1 => $blockId])]); - $form->addField("phone[$blockId][phone_ext]", ['entity' => 'phone', 'aria-label' => ts('Phone Extension %1', [1 => $blockId])]); + $form->addField("phone[$blockId][phone]", [ + 'entity' => 'phone', + 'class' => 'crm_phone twelve', + 'aria-label' => ts('Phone %1', [1 => $blockId]), + 'label' => ts('Phone %1:', [1 => $blockId]), + ]); + $form->addField("phone[$blockId][phone_ext]", [ + 'entity' => 'phone', + 'aria-label' => ts('Phone Extension %1', [1 => $blockId]), + 'label' => ts('ext.', ['context' => 'phone_ext']), + ]); if (isset($form->_contactType) || $blockEdit) { //Block type select $form->addField("phone[$blockId][location_type_id]", [ diff --git a/templates/CRM/Contact/Form/Edit/Phone.tpl b/templates/CRM/Contact/Form/Edit/Phone.tpl index 9e4131ca6e..aa7f6225c9 100644 --- a/templates/CRM/Contact/Form/Edit/Phone.tpl +++ b/templates/CRM/Contact/Form/Edit/Phone.tpl @@ -24,7 +24,7 @@ {/if} - {$form.phone.$blockId.phone.html} {ts context="phone_ext"}ext.{/ts} {$form.phone.$blockId.phone_ext.html|crmAddClass:four}  + {$form.phone.$blockId.phone.html} {$form.phone.$blockId.phone_ext.label} {$form.phone.$blockId.phone_ext.html|crmAddClass:four}  {if $className eq 'CRM_Contact_Form_Contact'} {$form.phone.$blockId.location_type_id.html} {/if} diff --git a/templates/CRM/Contact/Form/Inline/Phone.tpl b/templates/CRM/Contact/Form/Inline/Phone.tpl index dfa4bca072..b84bc1f718 100644 --- a/templates/CRM/Contact/Form/Inline/Phone.tpl +++ b/templates/CRM/Contact/Form/Inline/Phone.tpl @@ -31,7 +31,7 @@ {section name='i' start=1 loop=$totalBlocks} {assign var='blockId' value=$smarty.section.i.index} - {$form.phone.$blockId.phone.html} {ts context="phone_ext"}ext.{/ts} {$form.phone.$blockId.phone_ext.html|crmAddClass:four}  + {$form.phone.$blockId.phone.html} {$form.phone.$blockId.phone_ext.label} {$form.phone.$blockId.phone_ext.html|crmAddClass:four}  {$form.phone.$blockId.location_type_id.html} {$form.phone.$blockId.phone_type_id.html} {$form.phone.$blockId.is_primary.1.html} diff --git a/templates/CRM/Event/Form/ManageEvent/Location.tpl b/templates/CRM/Event/Form/ManageEvent/Location.tpl index 72f5d7bdf8..4f9074269e 100644 --- a/templates/CRM/Event/Form/ManageEvent/Location.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Location.tpl @@ -54,20 +54,20 @@ {include file="CRM/Contact/Form/Edit/Address.tpl" blockId=1} - + - + - - + + - - + +
{$form.email.1.email.label} {$form.email.1.email.html|crmAddClass:email}
{$form.email.2.email.label} {$form.email.2.email.html|crmAddClass:email}
{$form.phone.1.phone.html|crmAddClass:phone} {ts context="phone_ext"}ext.{/ts} {$form.phone.1.phone_ext.html|crmAddClass:four} {$form.phone.1.phone_type_id.html}{$form.phone.1.phone.label}{$form.phone.1.phone.html|crmAddClass:phone} {$form.phone.1.phone_ext.label} {$form.phone.1.phone_ext.html|crmAddClass:four} {$form.phone.1.phone_type_id.html}
{$form.phone.2.phone.html|crmAddClass:phone} {ts context="phone_ext"}ext.{/ts} {$form.phone.2.phone_ext.html|crmAddClass:four} {$form.phone.2.phone_type_id.html}{$form.phone.2.phone.label}{$form.phone.2.phone.html|crmAddClass:phone} {$form.phone.2.phone_ext.label} {$form.phone.2.phone_ext.html|crmAddClass:four} {$form.phone.2.phone_type_id.html}
-- 2.25.1