Disable Auto Completion in form

Disable Auto Completion in form

by Sandipa Mukherjee -
Number of replies: 1
Picture of Particularly helpful Moodlers

Hi All,

How to disable autocomplete in moodle form upon checkbox?

$users = $DB->get_records('<table_name>');

        $userssarr = array();

        foreach ($users as $user) {

            $userssarr[$tenant->id] = $user->id;

        }

        $options = array('multiple' => true, 'noselectionstring' => get_string('string', '<pluginname>'));

        $mform->addElement('checkbox', 'mycontrol', get_string('string2', '<pluginname>'));

        $mform->addElement('autocomplete',

        'userlist',

        get_string('userlist', '<pluginname>'), $userssarr, $options);

        $mform->addRule('userlist', get_string('missing', '<pluginname>'), 'required', null, 'server');

        $mform->disabledIf('userlist', 'mycontrol', 'neq', 0);

But this checkbox will not control the auto complete dropdown. Can anyone help me to solve it?


Thanks and regards,

Sandipa

Average of ratings: -
In reply to Sandipa Mukherjee

Re: Disable Auto Completion in form

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

I try to find a solution for your question and I found that ;

https://tracker.moodle.org/browse/MDL-57680
https://moodle.org/mod/forum/discuss.php?d=356376

you can add in a javascript something like that and check the value of the check box

$( document ).ready(function() {
setTimeout(function() { $('[id^=form_autocomplete_input]').prop( "disabled", true ); }, 3000);
});

Hope it's help.

Dominique.