From d0810e11e397dbcbfc294d45b45d8f71ec0d95d8 Mon Sep 17 00:00:00 2001 From: Zakaria Boushaba <48571684+Boushabazakaria@users.noreply.github.com> Date: Tue, 11 Aug 2026 18:46:22 +0100 Subject: [PATCH] FIX: Fix mandatory field validation for select (empty '-1') and textarea (CKEDITOR not defined) (#39458) Co-authored-by: Zakaria Boushaba --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c363460a8e4..e247203d284 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12055,7 +12055,7 @@ function printCommonFooter($zone = 'private') if (tmptypefield == 'textarea') { // We must instead check the content of ckeditor - var tmpeditor = CKEDITOR.instances['".dol_escape_js($paramkey)."']; + var tmpeditor = (typeof CKEDITOR !== 'undefined') ? CKEDITOR.instances['".dol_escape_js($paramkey)."'] : null; if (tmpeditor) { tmpvalue = tmpeditor.getData(); console.log('For textarea tmpvalue is '+tmpvalue); @@ -12063,7 +12063,7 @@ function printCommonFooter($zone = 'private') } let tmpvalueisempty = false; - if (tmpvalue === null || tmpvalue === undefined || tmpvalue === '' || tmpvalue === -1) { + if (tmpvalue === null || tmpvalue === undefined || tmpvalue === '' || tmpvalue === -1 || tmpvalue === '-1') { tmpvalueisempty = true; } if (tmpvalue === '0' && (tmptypefield == 'select' || tmptypefield == 'input')) {