From 13c93f77941fe678fe4d802dbebccbdd5cc74c13 Mon Sep 17 00:00:00 2001 From: tofulm Date: Thu, 12 May 2022 21:38:47 +0200 Subject: [PATCH] permet de gerer le cas des entiers plus precisement --- gamuform_fonctions.php | 15 +++++++++++---- json_gamuform.json.html | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gamuform_fonctions.php b/gamuform_fonctions.php index d5518b3..073856d 100644 --- a/gamuform_fonctions.php +++ b/gamuform_fonctions.php @@ -34,7 +34,7 @@ function gamuform_lang(?string $chaine):string { * * @return String valeur modifiée ou pas par le filtre */ -function gamufiltre($objet, $champ, $ligne) { +function gamufiltre($objet, $champ, $ligne, $integer = false) { $valeur = $ligne[$champ] ?? ''; if (gamuform_objet_autoriser($objet)) { $T = gamuform_recup_tableau_objet($objet); @@ -51,14 +51,14 @@ function gamufiltre($objet, $champ, $ligne) { if (strpos($filtre, '_array_') !== false) { $f = substr($filtre, 7); if (function_exists($f)) { - return $f($ligne) ?? ''; + return $f($ligne, $integer) ?? ''; } else if(function_exists($filtre)) { - return $filtre($ligne) ?? ''; + return $filtre($ligne, $integer) ?? ''; } else { return ''; } } else { - return $filtre($valeur) ?? ''; + return $filtre($valeur, $integer) ?? ''; } } } @@ -67,6 +67,13 @@ function gamufiltre($objet, $champ, $ligne) { return $valeur; } +function gamuTextebrut($v) { + if (is_integer($v)) { + return $v; + } + return trim(textebrut($v)); +} + /** * recuperation du tableau des saisies d'un objet * dans : gamuform/mon_objet.php diff --git a/json_gamuform.json.html b/json_gamuform.json.html index 7c6fd38..9b7252a 100644 --- a/json_gamuform.json.html +++ b/json_gamuform.json.html @@ -61,7 +61,7 @@ "id": #GET{ligne/id}, "edit": "", - [(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne}}|textebrut|json_encode)], + [(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne},integer}|gamuTextebrut|json_encode)], "sup":"" }