Merge branch 'MDL-73990-master' of https://github.com/sharidas/moodle
[moodle.git] / lib / form / searchableselector.php
blob1f487290ad1965bd34e81c2901d6d74cc8022eb4
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Searchable selector field (alias for autocomplete).
21 * Allows auto-complete selector.
23 * @package core_form
24 * @copyright 2015 Damyon Wiese <damyon@moodle.com>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 global $CFG;
29 require_once($CFG->libdir . '/form/autocomplete.php');
31 /**
32 * Form field type for selecting from a list of options.
34 * Allows auto-complete ajax searching.
36 * @package core_form
37 * @copyright 2015 Damyon Wiese <damyon@moodle.com>
38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40 class MoodleQuickForm_searchableselector extends MoodleQuickForm_autocomplete {
42 /**
43 * Constructor
45 * @param string $elementname Element name
46 * @param mixed $elementlabel Label(s) for an element
47 * @param array $options List of valid options for the select
48 * @param array $attributes List of HTML attributes for the select
50 public function __construct($elementname = null, $elementlabel = null, $options = [], $attributes = []) {
51 unset($options['']);
52 $options = ['' => get_string('noselection', 'form')] + $options;
53 parent::__construct($elementname, $elementlabel, $options, $attributes);
56 /**
57 * Old syntax of class constructor. Deprecated in PHP7.
59 * @deprecated since Moodle 3.1
61 public function MoodleQuickForm_searchableselector($elementName=null, $elementLabel=null, $options=null, $attributes=null) {
62 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
63 self::__construct($elementName, $elementLabel, $options, $attributes);