I can’t get the new form feature to work, Floating labels (Bootstrap 5) in Contact Form 7 (WordPress), the issue is that it breaks when a tag is added inside the tag, I think, idk.
Bootstrap template:
<div class="form-floating mb-3">
<input type="email" class="form-control" id="floatingInput" placeholder="[email protected]">
<label for="floatingInput">Email address</label>
</div>
Contact Form 7 example in editor:
<div class="form-floating mb-3"> [email emailExample id:floatingInput class:form-control]
<label for="floatingInput">Email address</label>
</div>
Contact Form 7 example after:
<div class="form-floating my-3">
<span class="wpcf7-form-control-wrap ignore">
<input type="email" name="ignore" value="" size="40" id="floatingInput" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-email form-control" aria-invalid="false">
</span>
<label for="floatingInput">Email address</label>
</div>
2
Answers
Try the following solution. Tweek class if needed
First of all you have to remove
<P>
and<SPAN>
from form.CF7 give us:
to remove P, but for SPAN, you have to add this line in functions.php
Now, in CF7, you can use
Floating labels will works as aspected but I agree with @Marko, using this hack, will not to display errors for missing fields.
Luca