diff --git a/apps/maarch_entreprise/indexing_searching/search_adv.php b/apps/maarch_entreprise/indexing_searching/search_adv.php index df05534df13269815e6ab201b9bdd22d09ed71fb..4e4a21d62617a622f0493f8248d98339293b06c5 100755 --- a/apps/maarch_entreprise/indexing_searching/search_adv.php +++ b/apps/maarch_entreprise/indexing_searching/search_adv.php @@ -137,8 +137,15 @@ foreach ($customFields as $customField) { $arr_tmp = array(); array_push($arr_tmp, array('VALUE' => '', 'LABEL' => _CHOOSE.'...')); $customValues = json_decode($customField['values'], true); - foreach ($customValues as $customValue) { - array_push($arr_tmp, array('VALUE' => $customValue, 'LABEL' => $customValue)); + if (!empty($customValues['table'])) { + $customValues = \CustomField\models\CustomFieldModel::getValuesSQL($customValues); + foreach ($customValues as $customInfo) { + array_push($arr_tmp, array('VALUE' => $customInfo['key'], 'LABEL' => $customInfo['label'])); + } + } else { + foreach ($customValues as $customValue) { + array_push($arr_tmp, array('VALUE' => $customValue, 'LABEL' => $customValue)); + } } $arr_tmp2 = array('label' => $customField['label'], 'type' => 'select_simple', 'param' => array('field_label' => $customField['label'], 'default_label' => '', 'options' => $arr_tmp)); } elseif ($customField['type'] == 'date') { diff --git a/src/app/customField/controllers/CustomFieldController.php b/src/app/customField/controllers/CustomFieldController.php index d514e70d3cff707c2f4dd3135def1081cb3ff7a2..20e2b95038eddd17d157d5dfe38b4e23c81ce9e3 100644 --- a/src/app/customField/controllers/CustomFieldController.php +++ b/src/app/customField/controllers/CustomFieldController.php @@ -44,7 +44,11 @@ class CustomFieldController if (empty($queryParams['admin']) || !PrivilegeController::hasPrivilege(['privilegeId' => 'admin_custom_fields', 'userId' => $GLOBALS['id']])) { if (!empty($customFields[$key]['values']['table'])) { $customFields[$key]['values'] = CustomFieldModel::getValuesSQL($customFields[$key]['values']); - if ($customField['type'] == 'string') { + if (in_array($customField['type'], ['select', 'radio', 'checkbox'])) { + foreach ($customFields[$key]['values'] as $iKey => $sValue) { + $customFields[$key]['values'][$iKey]['key'] = (string)$sValue['key']; + } + } elseif ($customField['type'] == 'string') { $customFields[$key]['values'][0]['key'] = (string)$customFields[$key]['values'][0]['key']; } elseif ($customField['type'] == 'integer') { $customFields[$key]['values'][0]['key'] = (int)$customFields[$key]['values'][0]['key']; diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php index a2fb30ed0819d5e22513bb9a45bf5d1bb1906fb1..38b2aca41c19629db3911b1d71b558826a8f9ae8 100755 --- a/src/app/resource/controllers/StoreController.php +++ b/src/app/resource/controllers/StoreController.php @@ -185,6 +185,13 @@ class StoreController $date = new \DateTime($value); $value = $date->format('Y-m-d'); $args['customFields'][$key] = $value; + } elseif ($customField['type'] != 'integer' && !is_array($value)) { + $args['customFields'][$key] = (string)$value; + } elseif ($customField['type'] != 'integer' && is_array($value)) { + foreach ($value as $iKey => $sValue) { + $value[$iKey] = (string)$sValue; + } + $args['customFields'][$key] = $value; } } } @@ -298,6 +305,13 @@ class StoreController $date = new \DateTime($value); $value = $date->format('Y-m-d'); $args['customFields'][$key] = $value; + } elseif ($customField['type'] != 'integer' && !is_array($value)) { + $args['customFields'][$key] = (string)$value; + } elseif ($customField['type'] != 'integer' && is_array($value)) { + foreach ($value as $iKey => $sValue) { + $value[$iKey] = (string)$sValue; + } + $args['customFields'][$key] = $value; } } $preparedData['custom_fields'] = json_encode($args['customFields']);