no_submit_button_actions($blogeditform, $sitecontext);
-} else if ($fromform = $blogeditform->data_submitted()){
+} else if ($fromform = $blogeditform->get_data()){
//save stuff in db
switch ($action) {
case 'add':
print_header("$SITE->shortname: $strblogs", $SITE->fullname,
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'">'.fullname($user).'</a> ->
<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$userid.'">'.$strblogs.'</a> -> '.$strformheading,'','',true);
-$blogeditform->set_defaults($post);
+$blogeditform->set_data($post);
$blogeditform->display();
$editform = new course_edit_form('edit.php', compact('course', 'category'));
// now override defaults if course already exists
if (!empty($course)) {
- $editform->set_defaults($course);
+ $editform->set_data($course);
}
if ($editform->is_cancelled()){
if (empty($course)) {
redirect($CFG->wwwroot.'/course/view.php?id='.$course->id);
}
- } elseif ($data = $editform->data_submitted()) {
+ } elseif ($data = $editform->get_data()) {
/// process data if submitted
//preprocess data
$mformclassname = 'mod_'.$module->name.'_mod_form';
$cousesection=isset($cw->section)?$cw->section:$section;
$mform=& new $mformclassname($form->instance, $cousesection, ((isset($cm))?$cm:null));
- $mform->set_defaults($form);
+ $mform->set_data($form);
if ($mform->is_cancelled()) {
if ($return && isset($cm)){
} else {
redirect("view.php?id=$course->id#section-".$cousesection);
}
- } elseif ($fromform=$mform->data_submitted()){
+ } elseif ($fromform=$mform->get_data()){
if (empty($fromform->coursemodule)) { //add
if (! $course = get_record("course", "id", $fromform->course)) {
error("This course doesn't exist");
redirect($CFG->wwwroot);
- }elseif ($data = $requestform->data_submitted()) {
+ }elseif ($data = $requestform->get_data()) {
$data->requester = $USER->id;
if (insert_record('course_request', $data)) {
else {
require_once($CFG->dirroot.'/enrol/authorize/enrol_form.php');
$frmenrol = new enrol_authorize_form();
- if ($frmenrol->data_submitted()) {
+ if ($frmenrol->get_data()) {
$authorizeerror = '';
switch ($form->paymentmethod) {
case AN_METHOD_CC:
* @param mixed $default_values object or array of default values
* @param bool $slased true if magic quotes applied to data values
*/
- function set_defaults($default_values, $slashed=false) {
+ function set_data($default_values, $slashed=false) {
if (is_object($default_values)) {
$default_values = (array)$default_values;
}
* @param bool $slashed true means return data with addslashes applied
* @return object submitted data; NULL if not valid or not submitted
*/
- function data_submitted($slashed=true) {
+ function get_data($slashed=true) {
$mform =& $this->_form;
if ($this->is_submitted() and $this->is_validated()) {
/**
* Dummy stub method - override if you need to setup the form depending on current
- * values. This method is called after definition(), data submission and set_defaults().
+ * values. This method is called after definition(), data submission and set_data().
* All form setup that is dependent on form values should go in here.
*/
function definition_after_data(){
* Use this method to a cancel and submit button to the end of your form. Pass a param of false
* if you don't want a cancel button in your form. If you have a cancel button make sure you
* check for it being pressed using is_cancelled() and redirecting if it is true before trying to
- * get data with data_submitted().
+ * get data with get_data().
*
* @param boolean $cancel whether to show cancel button, default true
* @param boolean $revert whether to show revert button, default true
/**
* Initializes a default form value. Used to specify the default for a new entry where
- * no data is loaded in using moodleform::set_defaults()
+ * no data is loaded in using moodleform::set_data()
*
* @param string $elementname element name
* @param mixed $values values for that element name
}
$mform = new login_change_password_form();
- $mform->set_defaults(array('id'=>$course->id, 'username'=>$USER->username));
+ $mform->set_data(array('id'=>$course->id, 'username'=>$USER->username));
if ($mform->is_cancelled()) {
redirect($CFG->wwwroot.'/user/view.php?id='.$USER->id.'&course='.$course->id);
- } else if ($data = $mform->data_submitted()) {
+ } else if ($data = $mform->get_data()) {
if (!has_capability('moodle/user:update', $sitecontext)) {
//ignore submitted username - the same is done in form validation
redirect($CFG->httpswwwroot.'/login/index.php');
}
-if ($action == 'find' and $param = $mform->data_submitted()) {
+if ($action == 'find' and $param = $mform->get_data()) {
///=====================
/// find the user in the database and mail info
///=====================
}
-if(!$mform->data_submitted()) {
+if(!$mform->get_data()) {
echo $strforgotteninstruct;
$mform->display();
}
if ($mform_signup->is_cancelled()) {
redirect($CFG->httpswwwroot.'/login/index.php');
- } else if ($user = $mform_signup->data_submitted()) {
+ } else if ($user = $mform_signup->get_data()) {
$plainpass = $user->password;
$user->password = hash_internal_user_password($plainpass);
$defaults->format = $submission->data2;
}
}
- $mform->set_defaults($defaults);
+ $mform->set_data($defaults);
if ($mform->is_cancelled()) {
redirect('view.php?id='.$this->cm->id);
}
- if ($data = $mform->data_submitted()) { // No incoming data?
+ if ($data = $mform->get_data()) { // No incoming data?
if ($editable && $this->update_submission($data)) {
//TODO fix log actions - needs db upgrade
$submission = $this->get_submission();
$defaults->text = '';
}
- $mform->set_defaults($defaults);
+ $mform->set_data($defaults);
if ($mform->is_cancelled()) {
redirect('view.php?id='.$this->cm->id);
die;
}
- if ($data = $mform->data_submitted() and $action == 'savenotes') {
+ if ($data = $mform->get_data() and $action == 'savenotes') {
$submission = $this->get_submission($USER->id, true); // get or create submission
$updated = new object();
$updated->id = $submission->id;
$mform = new mod_data_comment_form();
- $mform->set_defaults(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid));
+ $mform->set_data(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid));
if ($comment) {
$format = $comment->format;
$content = $comment->content;
$content = format_text($content, $format, $options);
$format = FORMAT_HTML;
}
- $mform->set_defaults(array('content'=>$content, 'format'=>$format));
+ $mform->set_data(array('content'=>$content, 'format'=>$format));
}
switch ($mode) {
case 'add':
- if (!$formadata = $mform->data_submitted()) {
+ if (!$formadata = $mform->get_data()) {
break; // something is wrong here, try again
}
break;
case 'edit': //print edit form
- if (!$formadata = $mform->data_submitted()) {
+ if (!$formadata = $mform->get_data()) {
break; // something is wrong here, try again
}
if (!$mform) {
require_once('comment_form.php');
$mform = new mod_data_comment_form('comment.php');
- $mform->set_defaults(array('mode'=>'add', 'page'=>$page, 'rid'=>$record->id));
+ $mform->set_data(array('mode'=>'add', 'page'=>$page, 'rid'=>$record->id));
}
echo '<div class="newcomment" style="text-align:center">';
$mform->display();
$mform_post = new mod_forum_post_form('post.php', array('course'=>$course, 'coursecontext'=>$coursecontext, 'modcontext'=>$modcontext, 'forum'=>$forum, 'post'=>$post));
- if ($fromform = $mform_post->data_submitted()) {
+ if ($fromform = $mform_post->get_data()) {
if (!empty($course->lang)) { // Override current language
(!empty($USER->autosubscribe));
- $mform_post->set_defaults(array( 'general'=>$heading,
+ $mform_post->set_data(array( 'general'=>$heading,
'subject'=>$post->subject,
'message'=>$post->message,
'subscribe'=>$subscribe?1:0,
}
$mform = new mod_glossary_comment_form();
- $mform->set_defaults(array('eid'=>$eid, 'action'=>'add'));
+ $mform->set_data(array('eid'=>$eid, 'action'=>'add'));
if ($mform->is_cancelled()) {
redirect("comments.php?id=$cm->id&eid=$entry->id");
}
- if ($data = $mform->data_submitted()) {
+ if ($data = $mform->get_data()) {
trusttext_after_edit($data->entrycomment, $context);
$newcomment = new object();
$mform = new mod_glossary_comment_form();
trusttext_prepare_edit($comment->entrycomment, $comment->format, can_use_html_editor(), $context);
- $mform->set_defaults(array('cid'=>$cid, 'action'=>'edit', 'entrycomment'=>$comment->entrycomment, 'format'=>$comment->format));
+ $mform->set_data(array('cid'=>$cid, 'action'=>'edit', 'entrycomment'=>$comment->entrycomment, 'format'=>$comment->format));
- if ($data = $mform->data_submitted()) {
+ if ($data = $mform->get_data()) {
trusttext_after_edit($data->entrycomment, $context);
$updatedcomment = new object();
redirect("view.php?id=$cm->id");
}
-} elseif ($fromform = $mform->data_submitted()) {
+} elseif ($fromform = $mform->get_data()) {
trusttext_after_edit($fromform->definition, $context);
if ( !isset($fromform->usedynalink) ) {
if ( $aliases = get_records_menu("glossary_alias", "entryid", $e, '', 'id, alias') ) {
$toform->aliases = implode("\n", $aliases) . "\n";
}
- $mform->set_defaults($toform);
+ $mform->set_data($toform);
}
}
if ($mform === null) {
print_error('missingimportantcode', 'question', $returnurl, 'question editing form definition');
}
-$mform->set_defaults($question);
+$mform->set_data($question);
if ($mform->is_cancelled()){
redirect($returnurl);
-} else if ($data = $mform->data_submitted()){
+} else if ($data = $mform->get_data()){
if (!empty($data->makecopy)) {
$question->id = 0; // causes a new question to be created.
$question->hidden = 0; // Copies should not be hidden
$userform = new user_edit_form(null, compact('user','course','authplugin'));
$userform->set_upload_manager(new upload_manager('imagefile',false,false,null,false,0,true,true));
- $userform->set_defaults($user);
+ $userform->set_data($user);
/// If data submitted, then process and store.
- if ($usernew = $userform->data_submitted()) {
+ if ($usernew = $userform->get_data()) {
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
// if userid = x and name = changeme then we are adding 1
redirect($redirect);
exit;
} else {
- if ($data = $categoryform->data_submitted()) {
+ if ($data = $categoryform->get_data()) {
if ($data->id == 0) {
unset($data->id);
$data->sortorder = count_records_select('user_info_category', '1') + 1;
redirect($redirect);
exit;
} else {
- if ($data = $fieldform->data_submitted()) {
+ if ($data = $fieldform->get_data()) {
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
$newfield = 'profile_field_'.$field->datatype;
$formfield = new $newfield($field->id);
$formfield->edit_field($mform);
/// override the defaults with the user settings
- $this->set_defaults($field);
+ $this->set_data($field);
$this->add_action_buttons(true);