MDL-77180 customfield: allow entry of formatted category names.

Change the param type of the category name when editing to allow
for entry of multilang tags, the formatting of which is already
supported when returning category name.

Co-authored-by: Hiroto Kagotani <hiroto.kagotani@gmail.com>
This commit is contained in:
Paul Holden 2023-02-08 21:48:52 +00:00
parent ef93325f27
commit 20280c0405
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
4 changed files with 7 additions and 3 deletions

View File

@ -254,7 +254,7 @@ class api {
$category->get_formatted_name(),
$category->get('name'),
get_string('editcategoryname', 'core_customfield'),
get_string('newvaluefor', 'core_form', format_string($category->get('name')))
get_string('newvaluefor', 'core_form', $category->get_formatted_name())
);
}

View File

@ -638,7 +638,7 @@ abstract class handler {
foreach ($fieldswithdata as $data) {
$categoryid = $data->get_field()->get_category()->get('id');
if ($categoryid != $lastcategoryid) {
$categoryname = format_string($data->get_field()->get_category()->get('name'));
$categoryname = $data->get_field()->get_category()->get_formatted_name();
// Load category header lang string if specified.
if (!empty($headerlangidentifier)) {

View File

@ -42,7 +42,7 @@ function core_customfield_inplace_editable($itemtype, $itemid, $newvalue) {
if (!$handler->can_configure()) {
throw new moodle_exception('nopermissionconfigure', 'core_customfield');
}
$newvalue = clean_param($newvalue, PARAM_NOTAGS);
$newvalue = clean_param($newvalue, PARAM_TEXT);
$handler->rename_category($category, $newvalue);
return \core_customfield\api::get_category_inplace_editable($category, true);
}

View File

@ -1,6 +1,10 @@
This files describes API changes in /customfield/*,
Information provided here is intended especially for developers.
=== 4.3 ===
* Field categories are now consistently of type `PARAM_TEXT`, ensure instance `get_formatted_name()` helper is used
during output
=== 4.2 ===
* The `\customfield_select\field_controller::get_options_array` method, deprecated since 3.10, has been removed, use
the field instance `get_options` method instead