From c7915cc95e7a8c4d45054156af066f99ee75af0b Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Thu, 28 Jun 2018 23:45:55 +0530 Subject: [PATCH] dev/accessibility#3: Add accessible label on Contact Edit form elements and helpicon --- CRM/Contact/Form/Edit/Email.php | 9 ++++----- CRM/Contact/Form/Edit/IM.php | 4 ++-- CRM/Contact/Form/Edit/Phone.php | 6 +++--- CRM/Contact/Form/Edit/Website.php | 2 +- CRM/Core/Smarty/plugins/function.help.php | 2 +- js/model/crm.uf.js | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CRM/Contact/Form/Edit/Email.php b/CRM/Contact/Form/Edit/Email.php index 489f5e7b32..47ed4a4489 100644 --- a/CRM/Contact/Form/Edit/Email.php +++ b/CRM/Contact/Form/Edit/Email.php @@ -58,7 +58,7 @@ class CRM_Contact_Form_Edit_Email { $form->applyFilter('__ALL__', 'trim'); //Email box - $form->addField("email[$blockId][email]", array('entity' => 'email')); + $form->addField("email[$blockId][email]", array('entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId]))); $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType) || $blockEdit) { //Block type @@ -77,17 +77,16 @@ class CRM_Contact_Form_Edit_Email { $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions); } else { - $form->addField("email[$blockId][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox')); + $form->addField("email[$blockId][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox', 'aria-label' => ts('On Hold for Email %1?', [1 => $blockId]))); } //Bulkmail checkbox $form->assign('multipleBulk', $multipleBulk); + $js = array('id' => "Email_" . $blockId . "_IsBulkmail" , 'aria-label' => ts('Bulk Mailing for Email %1?', [1 => $blockId])); if ($multipleBulk) { - $js = array('id' => "Email_" . $blockId . "_IsBulkmail"); $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js); } else { - $js = array('id' => "Email_" . $blockId . "_IsBulkmail"); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } @@ -95,7 +94,7 @@ class CRM_Contact_Form_Edit_Email { } //is_Primary radio - $js = array('id' => "Email_" . $blockId . "_IsPrimary"); + $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'aria-label' => ts('Email %1 is primary?', [1 => $blockId])); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } diff --git a/CRM/Contact/Form/Edit/IM.php b/CRM/Contact/Form/Edit/IM.php index f5df0b46aa..99a6bd719c 100644 --- a/CRM/Contact/Form/Edit/IM.php +++ b/CRM/Contact/Form/Edit/IM.php @@ -61,9 +61,9 @@ class CRM_Contact_Form_Edit_IM { $form->addField("im[$blockId][location_type_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL, 'option_url' => NULL)); //IM box - $form->addField("im[$blockId][name]", array('entity' => 'im')); + $form->addField("im[$blockId][name]", array('entity' => 'im', 'aria-label' => ts('Instant Messenger %1', [1 => $blockId]))); //is_Primary radio - $js = array('id' => 'IM_' . $blockId . '_IsPrimary'); + $js = array('id' => 'IM_' . $blockId . '_IsPrimary', 'aria-label' => ts('Instant Messenger %1 is primary?', [1 => $blockId])); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } diff --git a/CRM/Contact/Form/Edit/Phone.php b/CRM/Contact/Form/Edit/Phone.php index 756a96fca9..4262bcadd5 100644 --- a/CRM/Contact/Form/Edit/Phone.php +++ b/CRM/Contact/Form/Edit/Phone.php @@ -64,8 +64,8 @@ class CRM_Contact_Form_Edit_Phone { 'placeholder' => NULL, )); //main phone number with crm_phone class - $form->addField("phone[$blockId][phone]", array('entity' => 'phone', 'class' => 'crm_phone twelve')); - $form->addField("phone[$blockId][phone_ext]", array('entity' => 'phone')); + $form->addField("phone[$blockId][phone]", array('entity' => 'phone', 'class' => 'crm_phone twelve', 'aria-label' => ts('Phone %1', [1 => $blockId]))); + $form->addField("phone[$blockId][phone_ext]", array('entity' => 'phone', 'aria-label' => ts('Phone Extension %1', [1 => $blockId]))); if (isset($form->_contactType) || $blockEdit) { //Block type select $form->addField("phone[$blockId][location_type_id]", array( @@ -76,7 +76,7 @@ class CRM_Contact_Form_Edit_Phone { )); //is_Primary radio - $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );'); + $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );', 'aria-label' => ts('Phone %1 is primary?', [1 => $blockId])); $form->addElement('radio', "phone[$blockId][is_primary]", '', '', '1', $js); } // TODO: set this up as a group, we need a valid phone_type_id if we have a phone number diff --git a/CRM/Contact/Form/Edit/Website.php b/CRM/Contact/Form/Edit/Website.php index 160e84248d..43ade78cf4 100644 --- a/CRM/Contact/Form/Edit/Website.php +++ b/CRM/Contact/Form/Edit/Website.php @@ -58,7 +58,7 @@ class CRM_Contact_Form_Edit_Website { $form->addField("website[$blockId][website_type_id]", array('entity' => 'website', 'class' => 'eight')); //Website box - $form->addField("website[$blockId][url]", array('entity' => 'website')); + $form->addField("website[$blockId][url]", array('entity' => 'website', 'aria-label' => ts('Website URL %1', [1 => $blockId]))); $form->addRule("website[$blockId][url]", ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url'); } diff --git a/CRM/Core/Smarty/plugins/function.help.php b/CRM/Core/Smarty/plugins/function.help.php index c4e4836c98..f768965f61 100644 --- a/CRM/Core/Smarty/plugins/function.help.php +++ b/CRM/Core/Smarty/plugins/function.help.php @@ -92,5 +92,5 @@ function smarty_function_help($params, &$smarty) { foreach ($params as &$param) { $param = is_bool($param) || is_numeric($param) ? (int) $param : (string) $param; } - return ' '; + return ' '; } diff --git a/js/model/crm.uf.js b/js/model/crm.uf.js index a6ab2982ae..4f198c12a9 100644 --- a/js/model/crm.uf.js +++ b/js/model/crm.uf.js @@ -32,7 +32,7 @@ * Add a help link to a form label */ function addHelp(title, options) { - return title + ' '; + return title + ' '; } function watchChanges() { -- 2.25.1