diff --git a/gamuform_fonctions.php b/gamuform_fonctions.php index 22c8e3e..4cda0e5 100644 --- a/gamuform_fonctions.php +++ b/gamuform_fonctions.php @@ -23,18 +23,20 @@ if (!defined('_ECRIRE_INC_VERSION')) { * * @return String valeur modifiée ou pas par le filtre */ -function gamufiltre($objet, $champ, $valeur) { +function gamufiltre($objet, $champ, $ligne) { + $valeur = $ligne[$champ] ?? ''; if (gamuform_objet_autoriser($objet)) { $T = gamuform_recup_tableau_objet($objet); if (!empty($T)) { foreach ($T as $s) { if ( - $champ_tab = $s['gamutable']['champ'] ?? $s['options']['nom'] + (!empty($s['gamutable']) or !empty($s['options'])) + and $champ_tab = $s['gamutable']['champ'] ?? $s['options']['nom'] and $champ_tab === $champ and !empty($s['gamutable']['fonction']) ) { $filtre = $s['gamutable']['fonction']; - return $filtre($valeur) ?? ''; + return $filtre($valeur ?: $ligne) ?? ''; } } } @@ -243,17 +245,17 @@ function gamuform_recup_valeurs($objet, $id_objet = 0):array { if (gamuform_objet_autoriser($objet)) { $table = table_objet_sql($objet); $id = id_table_objet($objet); - $s = gamuform_recup_champs_gamutable($objet); + // $s = gamuform_recup_champs_gamutable($objet); - $s[] = $id; + // $s[] = $id; if (intval($id_objet)) { - $valeurs = sql_fetsel($s, $table, "$id=".intval($id_objet)); + $valeurs = sql_fetsel('*', $table, "$id=".intval($id_objet)); $valeurs['id'] = $valeurs[$id]; if (!empty($valeurs)) { $r[0] = $valeurs; } } else { - $T = sql_allfetsel($s, $table, 1); + $T = sql_allfetsel('*', $table, 1); if (!empty($T)) { foreach ($T as $t) { $t['id'] = $t[$id]; diff --git a/json_gamuform.json.html b/json_gamuform.json.html index 5cd7d23..976f058 100644 --- a/json_gamuform.json.html +++ b/json_gamuform.json.html @@ -57,7 +57,7 @@ "id": #GET{ligne/id}, "edit": [(#GET{edit}|json_encode)], - [(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|json_encode)], + [(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne}}|json_encode)], "sup": [(#GET{sup}|json_encode)] }, @@ -65,7 +65,7 @@ "id": #GET{ligne/id}, "edit": "", - [(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne/#VALEUR}}|textebrut|json_encode)], + [(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne}}|textebrut|json_encode)], "sup":"" }