Merge branch 'MDL-75788-master' of https://github.com/lameze/moodle

This commit is contained in:
Ilya Tregubov 2022-12-05 14:31:16 +03:00
commit ff871829c5
5 changed files with 44 additions and 17 deletions

View file

@ -1324,6 +1324,11 @@ EOD;
[$data['categoryid']]) + 1;
}
if ($data['datatype'] === 'menu' && isset($data['param1'])) {
// Convert new lines to the proper character.
$data['param1'] = str_replace('\n', "\n", $data['param1']);
}
// Defaults for other values.
$defaults = [
'description' => '',

View file

@ -577,5 +577,12 @@ class testing_generator_test extends \advanced_testcase {
$field7 = $generator->create_custom_profile_field(
['datatype' => 'checkbox', 'shortname' => 'areyousure', 'name' => 'Are you sure?']);
$this->assertEquals(0, $field7->defaultdata);
// Check setting options for menu using \n work as expected.
$field8 = $generator->create_custom_profile_field([
'datatype' => 'menu', 'shortname' => 'cuisine', 'name' => 'Cuisine', 'param1' => 'French\nChinese\nLebanese',
'defaultdata' => 'Chinese'
]);
$this->assertEquals("French\nChinese\nLebanese", $field8->param1);
}
}