I made an Astro site from the basic template Astro offers. I installed @astrojs/netlify
later on. I made a form that is on this page. I followed the instruction that is to activate the auto-detection then add ‘data-netlify=“true”’ or ‘netlify’ attribute to the form tag. So it what the source looks like:
<form name="contact" method="POST" data-netlify="true" class="flow">
<div>
<label for="nom">Nom :</label>
<input type="text" id="nom" name="nom" autofocus/>
</div>
<div>
<label for="sujet">Sujet :</label>
<input type="text" id="sujet" name="sujet"/>
</div>
<div>
<label for="email">Courriel :</label>
<input type="email" id="email" name="email"/>
</div>
<div>
<label for="message">Message :</label>
<textarea name="message" id="message" rows="5"></textarea>
</div>
<button class="btn btn-primary" type="submit">Envoyer</button>
</form>
This is what it compiled to dist:
<form name="contact" method="POST" data-netlify="true" class="flow" data-astro-cid-cbjbn2oj="">
<div data-astro-cid-cbjbn2oj="">
<label for="nom" data-astro-cid-cbjbn2oj="">Nom :</label>
<input type="text" id="nom" name="nom" autofocus="" data-astro-cid-cbjbn2oj="">
</div>
<div data-astro-cid-cbjbn2oj="">
<label for="sujet" data-astro-cid-cbjbn2oj="">Sujet :</label>
<input type="text" id="sujet" name="sujet" data-astro-cid-cbjbn2oj="">
</div>
<div data-astro-cid-cbjbn2oj="">
<label for="email" data-astro-cid-cbjbn2oj="">Courriel :</label>
<input type="email" id="email" name="email" data-astro-cid-cbjbn2oj="">
</div>
<div data-astro-cid-cbjbn2oj="">
<label for="message" data-astro-cid-cbjbn2oj="">Message :</label>
<textarea name="message" id="message" rows="5" data-astro-cid-cbjbn2oj="">
</textarea>
</div>
<button class="btn btn-primary" type="submit" data-astro-cid-cbjbn2oj="">Envoyer</button>
</form>
All it does is it refresh the page, but send nothing on my dashboard. I don’t use SSR nor frameworks for now, just the HTML.
I tried using “netlify” instead of ‘data-netlify=“true”’. I made several deploys trying to kick-in the form detector. I don’t know if there is a particular way to make it work with Astro on Netlify.
Thank you!