I follow instruction from API FIles moodle and I have error: Call to undefined method MoodleQuickForm::set_data()
There is my mod form:
class mod_finalassignment_mod_form extends moodleform_mod {
/**
* Defines forms elements
*/
public function definition() {
global $CFG, $USER, $COURSE;
$mform = $this->_form;
$params = $this->_customdata;
$
context = \context_course::instance($COURSE->id);
// Adding the "general" fieldset, where all the common settings are shown.
$mform->addElement('header', 'general', get_string('general', 'form'));
// Adding the standard "name" field.
$mform->addElement('text', 'name', get_string('finalassignmentname', 'finalassignment'), array('size' => '64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the standard "intro" and "introformat" fields.
if ($CFG->branch >= 29) {
$this->standard_intro_elements();
} else {
$this->add_intro_editor();
}
$mform->addElement('filemanager', 'finalassignment_file', get_string('coursecontent', 'mod_finalassignment'), null,
array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'areamaxbytes' => 10485760, 'maxfiles' => 50,
'accepted_types' => array('document'), 'return_types'=> FILE_INTERNAL | FILE_EXTERNAL));
if (empty($entry->id)) {
$entry = new stdClass;
$entry->id = null;
}
$draftitemid = file_get_submitted_draft_itemid('finalassignment');
file_prepare_draft_area($draftitemid, $context->id, 'mod_glossary', 'finalassignment_file', $entry->id,
array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'maxfiles' => 50));
$entry->attachments = $draftitemid;
$mform->set_data($entry);
$mform->addElement('duration', 'finalassignment_timelimit', get_string('timelimit', 'mod_finalassignment'));
$options = array(
'1' => 'On hole course',
'2' => 'On section'
);
$mform->addElement('select', 'finalassignment_select', get_string('select_options', 'mod_finalassignment'), $options);
// Add standard elements.
$this->standard_coursemodule_elements();
// Add standard buttons.
$this->add_action_buttons();
}
}