From 83e9f0ad7174b31a16c7a24b7b697754471eda75 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 30 Dec 2013 15:53:39 +0800 Subject: [PATCH] MDL-40119 Forms: Date selector should use images for the calendar popup toggle The calendar popup toggle must use an image, rather than an input with type of image as the latter is actually a form of submit button, and hence it steals the focus away from the real submit button. --- lib/form/dateselector.php | 6 ++++-- lib/form/datetimeselector.php | 6 ++++-- lib/form/yui/dateselector/dateselector.js | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/form/dateselector.php b/lib/form/dateselector.php index 9094d026057..2332e990e41 100644 --- a/lib/form/dateselector.php +++ b/lib/form/dateselector.php @@ -123,8 +123,10 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group { } // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. if ($calendartype->get_name() === 'gregorian') { - $this->_elements[] = @MoodleQuickForm::createElement('image', 'calendar', $OUTPUT->pix_url('i/calendar', 'moodle'), - array('title' => get_string('calendar', 'calendar'), 'class' => 'visibleifjs')); + $image = $OUTPUT->pix_icon('i/calendar', get_string('calendar', 'calendar'), 'moodle'); + $this->_elements[] = @MoodleQuickForm::createElement('link', 'calendar', + null, '#', $image, + array('class' => 'visibleifjs')); } // If optional we add a checkbox which the user can use to turn if on if ($this->_options['optional']) { diff --git a/lib/form/datetimeselector.php b/lib/form/datetimeselector.php index ff2fa993856..3153f34c100 100644 --- a/lib/form/datetimeselector.php +++ b/lib/form/datetimeselector.php @@ -139,8 +139,10 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group { } // The YUI2 calendar only supports the gregorian calendar type so only display the calendar image if this is being used. if ($calendartype->get_name() === 'gregorian') { - $this->_elements[] = @MoodleQuickForm::createElement('image', 'calendar', $OUTPUT->pix_url('i/calendar', 'moodle'), - array('title' => get_string('calendar', 'calendar'), 'class' => 'visibleifjs')); + $image = $OUTPUT->pix_icon('i/calendar', get_string('calendar', 'calendar'), 'moodle'); + $this->_elements[] = @MoodleQuickForm::createElement('link', 'calendar', + null, '#', $image, + array('class' => 'visibleifjs')); } // If optional we add a checkbox which the user can use to turn if on if ($this->_options['optional']) { diff --git a/lib/form/yui/dateselector/dateselector.js b/lib/form/yui/dateselector/dateselector.js index 1ea3669b9fe..2d332e29003 100644 --- a/lib/form/yui/dateselector/dateselector.js +++ b/lib/form/yui/dateselector/dateselector.js @@ -73,7 +73,7 @@ YUI.add('moodle-form-dateselector', function(Y) { }, this); // Loop through the input fields. - var inputs = this.get('node').all('input'); + var inputs = this.get('node').all('input, a'); inputs.each(function(node) { // Check if the current node is a calendar image field. if (node.get('name').match(/\[calendar]/)) {