diff --git a/src/_includes/partials/components/contact-form.njk b/src/_includes/partials/components/contact-form.njk index faf90ef..aee53c1 100644 --- a/src/_includes/partials/components/contact-form.njk +++ b/src/_includes/partials/components/contact-form.njk @@ -1,9 +1,13 @@ -{% from "macros/form.njk" import label, field, select, option, textarea, checkboxes, button %} +{% from "macros/form.njk" import label, field, select, option, textarea, checkboxes, button, hidden_field %}
- + {% if not contactMember %} + + {% endif %}
-

Nous contacter

+ {% if not contactMember %} +

Nous contacter

+ {% endif %}
  1. @@ -16,20 +20,31 @@
  2. {{ label("Je vous contacte pour :", "select") }} - {{ select( "select", [ - {label: "Obtenir un rendez-vous (décrivez votre projet en quelques lignes)", value: "option 1"}, - {label: "Obtenir des précisions sur le statut d’entrepreneur salarié", value: "option 2"}, - {label: "Proposer une mission à un coopérateur", value: "option 3"}, - {label: "Proposer un partenariat", value: "option 4"} - ], { required: true, options_before: [""], options_after: ["Autre demande"] } ) }} + {% if contactMember %} + {{ select( "select", [ + {label: "Obtenir un rendez-vous (décrivez votre projet en quelques lignes)", value: "option 1"}, + {label: "Proposer une mission à un coopérateur", value: "option 3"} + ], { required: true, options_before: [""], options_after: ["Autre demande"] } ) }} + {% else %} + {{ select( "select", [ + {label: "Obtenir un rendez-vous (décrivez votre projet en quelques lignes)", value: "option 1"}, + {label: "Obtenir des précisions sur le statut d’entrepreneur salarié", value: "option 2"}, + {label: "Proposer une mission à un coopérateur", value: "option 3"}, + {label: "Proposer un partenariat", value: "option 4"} + ], { required: true, options_before: [""], options_after: ["Autre demande"] } ) }} + {% endif %}
  3. {{ label("Votre message", "message") }} {{ textarea( "message", { required: true, autocapitalize: "sentences", spellcheck: "true" } ) }}
  4. -
  5. - {{ checkboxes("", "subscribe", [ "Je souhaite être tenu au courant de l’actualité Astrolabe"], { description: "" } ) }} -
  6. + {% if contactMember %} + {{ hidden_field('subscribe', '') }} + {% else %} +
  7. + {{ checkboxes("", "subscribe", [ "Je souhaite être tenu au courant de l’actualité Astrolabe"], { description: "" } ) }} +
  8. + {% endif %}
+ {% if contactMember %} + {{ hidden_field('contactTo', contactMember) }} + {% endif %} {{ button("Envoyer") }}
diff --git a/src/form/contact-form-handler.php b/src/form/contact-form-handler.php index 7fffbb1..3fbbd3e 100644 --- a/src/form/contact-form-handler.php +++ b/src/form/contact-form-handler.php @@ -15,13 +15,11 @@ $domainFromMyEmail = ( : $myEmailSplitted[1]; $wantedContact = filter_input(INPUT_POST, 'contactTo', FILTER_VALIDATE_EMAIL); -if ( +$wantedContact = ( empty($wantedContact) || empty($domainFromMyEmail) || substr($wantedContact, -strlen($domainFromMyEmail)) != $domainFromMyEmail -) { - $wantedContact = $myEmail; -} +) ? $myEmail : "$wantedContact@$domainFromMyEmail" ; if(empty($_POST['namezzz']) || empty($_POST['emailzzz']) || empty($_POST['message'])) { $errors .= "\n Error: all fields are required";