permet de gerer le cas des entiers plus precisement

This commit is contained in:
Christophe 2022-05-12 21:38:47 +02:00
parent 49e7f583c7
commit 13c93f7794
2 changed files with 12 additions and 5 deletions

View file

@ -34,7 +34,7 @@ function gamuform_lang(?string $chaine):string {
* *
* @return String valeur modifiée ou pas par le filtre * @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] ?? ''; $valeur = $ligne[$champ] ?? '';
if (gamuform_objet_autoriser($objet)) { if (gamuform_objet_autoriser($objet)) {
$T = gamuform_recup_tableau_objet($objet); $T = gamuform_recup_tableau_objet($objet);
@ -51,14 +51,14 @@ function gamufiltre($objet, $champ, $ligne) {
if (strpos($filtre, '_array_') !== false) { if (strpos($filtre, '_array_') !== false) {
$f = substr($filtre, 7); $f = substr($filtre, 7);
if (function_exists($f)) { if (function_exists($f)) {
return $f($ligne) ?? ''; return $f($ligne, $integer) ?? '';
} else if(function_exists($filtre)) { } else if(function_exists($filtre)) {
return $filtre($ligne) ?? ''; return $filtre($ligne, $integer) ?? '';
} else { } else {
return ''; return '';
} }
} else { } else {
return $filtre($valeur) ?? ''; return $filtre($valeur, $integer) ?? '';
} }
} }
} }
@ -67,6 +67,13 @@ function gamufiltre($objet, $champ, $ligne) {
return $valeur; return $valeur;
} }
function gamuTextebrut($v) {
if (is_integer($v)) {
return $v;
}
return trim(textebrut($v));
}
/** /**
* recuperation du tableau des saisies d'un objet * recuperation du tableau des saisies d'un objet
* dans : gamuform/mon_objet.php * dans : gamuform/mon_objet.php

View file

@ -61,7 +61,7 @@
"id": #GET{ligne/id}, "id": #GET{ligne/id},
"edit": "", "edit": "",
<BOUCLE_champsB(DATA){source table,#GET{champs}}> <BOUCLE_champsB(DATA){source table,#GET{champs}}>
[(#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)],
</BOUCLE_champsB> </BOUCLE_champsB>
"sup":"" "sup":""
} }