From 9c05115c9cca8cad67086d856c385f3ebb9957a5 Mon Sep 17 00:00:00 2001 From: Nonimart Date: Tue, 21 Oct 2025 10:22:11 +0200 Subject: [PATCH] FEATURE Handling thematique field population for contribution form --- functions.php | 1 + includes/gravity-forms.php | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 includes/gravity-forms.php diff --git a/functions.php b/functions.php index eb2501a..17619cb 100644 --- a/functions.php +++ b/functions.php @@ -14,3 +14,4 @@ require_once(__DIR__ . '/includes/api.php'); require_once(__DIR__ . '/includes/renderPostsDatas.php'); require_once(__DIR__ . '/includes/utilities.php'); require_once(__DIR__ . '/includes/featured-revues.php'); +require_once(__DIR__ . '/includes/gravity-forms.php'); diff --git a/includes/gravity-forms.php b/includes/gravity-forms.php new file mode 100644 index 0000000..1c2b3dd --- /dev/null +++ b/includes/gravity-forms.php @@ -0,0 +1,39 @@ + 'etiquettes', + 'hide_empty' => false, // Include empty terms + )); + + // Prepare choices array for the select field + $choices = array(); + foreach ($terms as $term) { + $choices[] = array( + 'text' => $term->name, + 'value' => $term->term_id, + ); + } + + // Find the select field by ID + foreach ($form['fields'] as &$field) { + if ($field->id == $field_id) { + // Update choices for the select field + $field->choices = $choices; + break; + } + } + } + + return $form; +}