/**
  * Edit the plugin instance
  *
  * @param object $plugin
  */
 public final function edit($report_id, $plugin_id, $reportfield_id)
 {
     global $CFG, $PARSER, $USER;
     //get the report field record
     $reportfield = $this->dbc->get_report_field_data($reportfield_id);
     // include the moodle form library
     require_once $CFG->libdir . '/formslib.php';
     //include ilp_formslib
     require_once $CFG->dirroot . '/blocks/ilp/classes/ilp_formslib.class.php';
     // get the name of the evidence class being edited
     $classname = get_class($this) . '_mform';
     // include the moodle form for this table
     include_once "{$CFG->dirroot}/blocks/ilp/classes/form_elements/plugins/{$classname}.php";
     if (!class_exists($classname)) {
         print_error('noeditilpform', 'block_ilp', '', get_class($this));
     }
     if (!empty($reportfield->id)) {
         $plugin = $this->dbc->get_form_element_plugin($reportfield->plugin_id);
         //get the form element data from the plugin table
         $form_element = $this->dbc->get_form_element_by_reportfield($plugin->tablename, $reportfield->id);
         $non_attrib = array('id', 'timemodified', 'timecreated');
         if (!empty($form_element)) {
             foreach ($form_element as $attrib => $value) {
                 if (!in_array($attrib, $non_attrib)) {
                     $reportfield->{$attrib} = $value;
                 }
             }
         }
         $this->return_data($reportfield);
     } else {
         //new element - check for config file
         if (file_exists($this->local_config_file)) {
             $reportfield->optionlist = self::itemlist_flatten(parse_ini_file($this->local_config_file));
         }
     }
     // instantiate the form and load the data
     $this->mform = new $classname($report_id, $plugin_id, $USER->id);
     $this->mform->set_data($reportfield);
     //enter a back u
     $backurl = $CFG->wwwroot . "/blocks/ilp/actions/edit_prompt.php?report_id={$report_id}";
     //was the form cancelled?
     if ($this->mform->is_cancelled()) {
         //send the user back
         redirect($backurl, get_string('returnreportprompt', 'block_ilp'), ILP_REDIRECT_DELAY);
     }
     //was the form submitted?
     // has the form been submitted?
     if ($this->mform->is_submitted()) {
         // check the validation rules
         if ($this->mform->is_validated()) {
             //get the form data submitted
             $formdata = $this->mform->get_data();
             $formdata->audit_type = $this->audit_type();
             // process the data
             $success = $this->mform->process_data($formdata);
             //if saving the data was not successful
             if (!$success) {
                 //print an error message
                 print_error(get_string("fieldcreationerror", 'block_ilp'), 'block_ilp');
             }
             if ($this->mform->is_submitted()) {
                 //return the user to the
                 $return_url = $CFG->wwwroot . "/blocks/ilp/actions/edit_prompt.php?report_id={$report_id}";
                 redirect($return_url, get_string("fieldcreationsuc", 'block_ilp'), ILP_REDIRECT_DELAY);
             }
         }
     }
 }