Skip to content

Commit

Permalink
MDL-71051 core_user: move user profile edit field form to classes
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Apr 28, 2021
1 parent abb2c72 commit ac494c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 2 additions & 3 deletions calendar/tests/calendartype_test.php
Expand Up @@ -36,7 +36,6 @@
// Used to test the user datetime profile field.
require_once($CFG->dirroot . '/user/profile/lib.php');
require_once($CFG->dirroot . '/user/profile/definelib.php');
require_once($CFG->dirroot . '/user/profile/index_field_form.php');

/**
* Unit tests for the calendar type system.
Expand Down Expand Up @@ -275,10 +274,10 @@ private function datetime_field_submission_test($type, $date) {
$formdata['param2'] = $date['inputmaxyear'];

// Mock submitting this.
field_form::mock_submit($formdata);
\core_user\form\profile_field_form::mock_submit($formdata);

// Create the user datetime form.
$form = new field_form(null, 'datetime');
$form = new \core_user\form\profile_field_form(null, 'datetime');

// Get the data from the submission.
$submissiondata = $form->get_data();
Expand Down
Expand Up @@ -22,9 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
namespace core_user\form;

use profile_define_base;

defined('MOODLE_INTERNAL') || die;

require_once($CFG->dirroot.'/lib/formslib.php');

Expand All @@ -34,7 +36,7 @@
* @copyright 2007 onwards Shane Elliot {@link http://pukunui.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class field_form extends moodleform {
class profile_field_form extends \moodleform {

/** @var profile_define_base $field */
public $field;
Expand Down
3 changes: 1 addition & 2 deletions user/profile/definelib.php
Expand Up @@ -575,8 +575,7 @@ function profile_edit_field($id, $datatype, $redirect) {
$field->description = clean_text($field->description, $field->descriptionformat);
$field->description = array('text' => $field->description, 'format' => $field->descriptionformat, 'itemid' => 0);

require_once($CFG->dirroot.'/user/profile/index_field_form.php');
$fieldform = new field_form(null, $field->datatype);
$fieldform = new \core_user\form\profile_field_form(null, $field->datatype);

// Convert the data format for.
if (is_array($fieldform->editors())) {
Expand Down

0 comments on commit ac494c7

Please sign in to comment.