From 9488e225180ce35ac9d8cd6ccd94ee8e5fc1debb Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Thu, 4 May 2023 12:17:29 +0200 Subject: [PATCH] MOBILE-4247 edit: Add field#name and field#description --- src/addons/mod/data/pages/edit/edit.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index a53dc4559..e6452eab5 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -438,6 +438,20 @@ export class AddonModDataEditPage implements OnInit { replaceRegEx = new RegExp(replace, 'gi'); template = template.replace(replaceRegEx, 'field_' + field.id); + + // Replace the field name tag. + replace = '[[' + field.name + '#name]]'; + replace = replace.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); + replaceRegEx = new RegExp(replace, 'gi'); + + template = template.replace(replaceRegEx, field.name); + + // Replace the field description tag. + replace = '[[' + field.name + '#description]]'; + replace = replace.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); + replaceRegEx = new RegExp(replace, 'gi'); + + template = template.replace(replaceRegEx, field.description); }); const regex = new RegExp('##otherfields##', 'gi');