本文整理匯總了PHP中moodleform::process_data方法的典型用法代碼示例。如果您正苦於以下問題:PHP moodleform::process_data方法的具體用法?PHP moodleform::process_data怎麽用?PHP moodleform::process_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類moodleform
的用法示例。
在下文中一共展示了moodleform::process_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
/**
* 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);
}
}
}
}