Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
11 efrain 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.
13
//
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/>.
16
 
17
require_once(__DIR__ . '/../../../../../config.php');
18
 
19
//defined('BEHAT_SITE_RUNNING') || die();
20
 
21
global $CFG, $PAGE, $OUTPUT;
22
require_once($CFG->libdir . '/formslib.php');
23
$PAGE->set_url('/lib/form/tests/behat/fixtures/editor_hideif_disabledif_form.php');
24
$PAGE->add_body_class('limitedwidth');
25
require_login();
26
$PAGE->set_context(core\context\system::instance());
27
 
28
/**
29
 * Test class for disabling and hiding a text area using an editor.
30
 *
31
 * @package   core_form
32
 * @copyright 2024 David Woloszyn <david.woloszyn@moodle.com>
33
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
35
class test_editor_hideif_disabledif_form extends moodleform {
36
 
37
    /**
38
     * Form definition.
39
     */
40
    public function definition(): void {
41
        $mform = $this->_form;
42
 
43
        // Radio buttons.
44
        $radiogroup = [
45
            $mform->createElement('radio', 'some_radios', '', 'Enable', '1'),
46
            $mform->createElement('radio', 'some_radios', '', 'Disable', '2'),
47
            $mform->createElement('radio', 'some_radios', '', 'Hide', '3'),
48
        ];
49
 
50
        $mform->addGroup($radiogroup, 'some_radios_group', 'Enable/Disable/Hide', ' ', false);
51
        $mform->setDefault('some_radios', 1);
52
 
53
        // Editor with conditions.
54
        $mform->addElement('editor', 'some_editor', 'My test editor');
55
        $mform->disabledIf('some_editor', 'some_radios', 'eq', '2');
56
        $mform->hideIf('some_editor', 'some_radios', 'eq', '3');
57
 
58
        $this->add_action_buttons();
59
    }
60
}
61
 
62
$form = new test_editor_hideif_disabledif_form();
63
 
64
echo $OUTPUT->header();
65
$form->display();
66
echo $OUTPUT->footer();