From aba5a131c2f4a69c511bcce5bec40e4763133941 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 25 May 2020 14:46:41 +0200 Subject: [PATCH] LSformElement::select_object: fix selection via LSselect on create form --- .../class/class.LSformElement_select_object.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/includes/class/class.LSformElement_select_object.php b/src/includes/class/class.LSformElement_select_object.php index a563c8aa..27a05cb7 100644 --- a/src/includes/class/class.LSformElement_select_object.php +++ b/src/includes/class/class.LSformElement_select_object.php @@ -246,18 +246,26 @@ class LSformElement_select_object extends LSformElement { if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) { if (LSsession ::loadLSobject($_REQUEST['objecttype'])) { $object = new $_REQUEST['objecttype'](); - if ($object -> loadData($_REQUEST['objectdn'])) { + if ($_REQUEST['idform'] == 'create' || ($_REQUEST['objectdn'] && $object -> loadData($_REQUEST['objectdn']))) { $form = $object -> getForm($_REQUEST['idform']); - $field=$form -> getElement($_REQUEST['attribute']); + $field = $form -> getElement($_REQUEST['attribute']); $val = $field -> getValuesFromLSselect(); - if ( $val ) { + if ( is_array($val) ) { $data = array( 'objects' => $val ); } + else + self :: log_debug('ajax_refresh(): invalid return of $field -> getValuesFromLSselect()'); } + else + self :: log_error("ajax_refresh(): Fail to load data of object ".$_REQUEST['objecttype']." from DN '".$_REQUEST['objectdn']."'"); } + else + self :: log_error("ajax_refresh(): Fail to load object type '".$_REQUEST['objecttype']."'"); } + else + self :: log_error("ajax_refresh(): some parameter(s) are missing"); } /**