From 1f1410dc2cab529b5e33a779ebba2f19f6ded2c9 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Fri, 25 May 2018 17:54:15 +0530 Subject: [PATCH] dev/accessiblity#3 Add aria-label to datepicker element --- CRM/Core/Form.php | 3 +++ js/Common.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 908bdfebbe..113411d7ff 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -376,6 +376,9 @@ class CRM_Core_Form extends HTML_QuickForm_Page { if ($type == 'datepicker') { $attributes = ($attributes ? $attributes : array()); $attributes['data-crm-datepicker'] = json_encode((array) $extra); + if (!empty($attributes['aria-label']) || $label) { + $attributes['aria-label'] = CRM_Utils_Array::value('aria-label', $attributes, $label); + } $type = "text"; } if ($type == 'select' && is_array($extra)) { diff --git a/js/Common.js b/js/Common.js index 43cc526b72..0460403c79 100644 --- a/js/Common.js +++ b/js/Common.js @@ -690,6 +690,7 @@ if (!CRM.vars) CRM.vars = {}; $timeField .addClass('crm-form-text crm-form-time') .attr('placeholder', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder')) + .attr('aria-label', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder')) .change(updateDataField) .timeEntry({ spinnerImage: '', @@ -699,7 +700,7 @@ if (!CRM.vars) CRM.vars = {}; if (settings.date !== false) { // Render "number" field for year-only format, calendar popup for all other formats $dateField = $('').insertAfter($dataField); - copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled']); + copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled', 'aria-label']); $dateField.addClass('crm-form-' + type); if (hasDatepicker) { settings.minDate = settings.minDate ? CRM.utils.makeDate(settings.minDate) : null; -- 2.25.1