Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-26167

disabledIf doesn't work on filepicker form elements

XMLWordPrintable

    • MOODLE_20_STABLE
    • MOODLE_20_STABLE

      The nifty Javascript that $mform->disabledIf() uses to switch form elements to "disabled" doesn't work with a filepicker element. Sample code:

      // ... in a form definition
      $mform->addElement('select','enabler','Enable other form elements?', array(0=>'No',1=>'Yes'));

      // A text field will enable/disable properly
      $mform->addElement('text','foo','This is a text field');
      $mform->disabledIf('foo','enabler','neq',1);

      // A filepicker will remain enabled no matter what
      $filemanager_options = array();
      $filemanager_options['return_types'] = 3;
      $filemanager_options['accepted_types'] = 'web_image';
      $filemanager_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes);
      $mform->addElement('filepicker', 'bar', 'This is a filepicker', null, $filemanager_options);
      $mform->disabledIf('bar','enabler','neq',1);

            danmarsden Dan Marsden
            aaronw@catalyst.net.nz Aaron Wells
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.