"MDL-13766, added missing js init call"
authorDongsheng Cai <unoter@gmail.com>
Mon, 31 May 2010 09:41:46 +0000 (09:41 +0000)
committerDongsheng Cai <unoter@gmail.com>
Mon, 31 May 2010 09:41:46 +0000 (09:41 +0000)
lib/form/filepicker.php

index cc15aca..b68d6df 100644 (file)
@@ -77,14 +77,16 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
         $args->itemid = $draftitemid;
         $args->context = $PAGE->context;
 
-        $str = $this->_getTabs();
+        $html = $this->_getTabs();
         $fp = new file_picker($args);
         $options = $fp->options;
-        $str .= $OUTPUT->render($fp);
-        $str .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" value="'.$draftitemid.'" />';
-        // label element needs 'for' attribute work
-        $html .= '<input value="" id="id_'.$elname.'" type="hidden" />';
-        return $str;
+        $html .= $OUTPUT->render($fp);
+        $html .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" value="'.$draftitemid.'" />';
+
+        $module = array('name'=>'form_filepicker', 'fullpath'=>'/lib/form/filepicker.js', 'requires'=>array('core_filepicker'));
+        $PAGE->requires->js_init_call('M.form_filepicker.init', array($fp->options), true, $module);
+
+        return $html;
     }
 
     function exportValue(&$submitValues, $assoc = false) {