MOBILE-2693 data: Do not allow saving blank required textarea fields

main
Albert Gasset 2018-10-17 14:37:05 +02:00
parent c54d061e55
commit 0d646e738e
1 changed files with 6 additions and 5 deletions

View File

@ -55,6 +55,11 @@ export class AddonModDataFieldTextareaHandler extends AddonModDataFieldTextHandl
// Add some HTML to the text if needed. // Add some HTML to the text if needed.
text = this.textUtils.formatHtmlLines(text); text = this.textUtils.formatHtmlLines(text);
// WS does not properly check if HTML content is blank when the field is required.
if (this.textUtils.htmlIsBlank(text)) {
text = '';
}
return [ return [
{ {
fieldid: field.id, fieldid: field.id,
@ -99,11 +104,7 @@ export class AddonModDataFieldTextareaHandler extends AddonModDataFieldTextHandl
} }
const found = inputData.some((input) => { const found = inputData.some((input) => {
if (!input.subfield) { return !input.subfield && this.textUtils.htmlIsBlank(input.value);
return !!input.value;
}
return false;
}); });
if (!found) { if (!found) {