0

I need to do it without javascript.

For example, the form HTML rendered on the page normally looks like this:

<form action="/contact-us/#wpcf7-f713-p61-o1" method="post" class="wpcf7-form submitting" novalidate="novalidate" data-status="submitting">

But I need to add the custom attribue data-netlify="true" so the form should end up like this:

<form action="/contact-us/#wpcf7-f713-p61-o1" method="post" class="wpcf7-form submitting" novalidate="novalidate" data-status="submitting" data-netlify="true">

There is a similar question over here. But that is for putting a custom attribute on the input, I need the custom attribute on the form itself.

TinyTiger
  • 1,801
  • 7
  • 47
  • 92
  • If you browse the source code `contact-form.php` line 500 - you'll see that there are no filters to add additional attributes to the `` tag, and anything passed to the existing filters that could possibly do this are sanitized, like the `autocomplete` filter. It would seem that javascript might be your only route here. – Howard E May 11 '22 at 09:59

1 Answers1

0

If the action always is the same on the form you could use javascript to add it

<script>
  var data = document.querySelector('[action="/contact-us/#wpcf7-f713-p61-o1"]');
  data.setAttribute('data-netlify', true);
  console.log(data);
</script>
Locos
  • 105
  • 1
  • 8