How does Netlify Forms determine labels in email notifications?

We have a form that uses the same labels for a few different fields, for example:

<label>Name</label>
<input name="shipping-name">
...
<label>Name</label>
<input name="billing-name">

In the emails that Netlify sends out, these labels are clobbering each other. For example, a form with a shipping-name of “John” and a billing-name of “Jane” only includes “Name: Jane”.

Is Netlify determining the label name by what’s adjacent to the input? By the for attribute? How can we override this? I can’t find anything in the documentation about this.

1 Like

Hi, @charlie1, we don’t handle ‘for’ attributes for certain fields so I recommend you using labels like so:

<label>Name
    <input name="shipping-name"> 
</label>

Basically wrapping the label element around your input field indicates which input field that label is for.

Thanks for getting back to me, Dennis.

We currently have a form with the labels setup just as I’ve suggested (well, they also have for attributes) and the labels are coming over in the email and clobbering like-named labels.

Can you speak to that issue?

As with input names, you’ll want to avoid duplicate labels. That said, I do have an issue filed regarding this issue and will update here if and when we get a change deployed to handle that issue.