From 9d1b74a45513cc6874ed57bd12e101bebc1b9f42 Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Mon, 7 Jan 2019 13:21:10 +0100 Subject: [PATCH] MOBiLE-2795 data: Fix saving entry with required URL field --- .../mod/data/fields/url/providers/handler.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/addon/mod/data/fields/url/providers/handler.ts b/src/addon/mod/data/fields/url/providers/handler.ts index 7e6ea803e..ae8eb55d5 100644 --- a/src/addon/mod/data/fields/url/providers/handler.ts +++ b/src/addon/mod/data/fields/url/providers/handler.ts @@ -40,6 +40,25 @@ export class AddonModDataFieldUrlHandler extends AddonModDataFieldTextHandler { return AddonModDataFieldUrlComponent; } + /** + * Get field edit data in the input data. + * + * @param {any} field Defines the field to be rendered. + * @param {any} inputData Data entered in the edit form. + * @return {any} With name and value of the data to be sent. + */ + getFieldEditData(field: any, inputData: any, originalFieldData: any): any { + const fieldName = 'f_' + field.id; + + return [ + { + fieldid: field.id, + subfield: '0', + value: inputData[fieldName] || '' + } + ]; + } + /** * Check and get field requeriments. *