Hey,
I’m having a weird issue with netlify forms where the form is well detected, when i post it i get a 200, and further more i get the “Last submission” date in the list of forms that is updated everytime i submit the form. Unfortunately submissions still do not show and i have no idea why. You can see the form in action here: Expression - Formation en prise de parole
Here’s my react setup.
static form in index for netlify to detect:
<form name="contact" netlify netlify-honeypot="bot-field" hidden>
<input type="text" name="name" />
<input type="email" name="email" />
<input type="tel" name="phone" />
<textarea name="message"></textarea>
</form>
Then my react component
export function Contact() {
const {
register,
handleSubmit,
formState: { errors },
reset
} = useForm<ContactForm>({
resolver: zodResolver(contactSchema),
});
const onSubmit = async (data: ContactForm) => {
try {
const response = await fetch('/', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
'form-name': 'contact',
...data
}).toString()
});
if (response.ok) {
alert('Message envoyé avec succès !');
reset();
} else {
throw new Error('Erreur lors de l\'envoi');
}
} catch (error) {
console.error('Erreur lors de l\'envoi', error);
alert('Une erreur est survenue. Toutes nos excuses.');
}
};
And further down the form definition:
<form
name="contact"
method="POST"
data-netlify="true"
netlify-honeypot="bot-field"
onSubmit={handleSubmit(onSubmit)}
className="space-y-6"
>
<input type="hidden" name="form-name" value="contact" />
<p className="hidden">
<label>
Don't fill this out if you're human: <input name="bot-field" />
</label>
</p>
<Input
label="Nom"
{...register('name')}
placeholder="Ex: Jean Dupont"
error={errors.name?.message}
name="name"
/>
<Input
label="Email"
type="email"
{...register('email')}
placeholder="Ex: jean.dupont@email.com"
error={errors.email?.message}
name="email"
/>
<Input
label="Téléphone"
type="tel"
{...register('phone')}
placeholder="Ex: 06 12 34 56 78"
error={errors.phone?.message}
name="phone"
/>
<Textarea
label="Votre besoin"
{...register('message')}
rows={5}
placeholder="Ex: Je souhaite améliorer les compétences en prise de parole de mes équipes..."
error={errors.message?.message}
name="message"
/>
<motion.button
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
type="submit"
className="w-full bg-primary text-white py-3 rounded-md font-medium inline-flex items-center justify-center group"
>
Envoyer
<Send className="ml-2 w-4 h-4 transition-transform group-hover:translate-x-1" />
</motion.button>
</form>