Search code examples
phphtmlvalidationfrontendshopware

Additional required fields in checkout frontend in shopware 5


I am working on a payment method and I need to add one additional checkbox for a specific payment method.

<input type="checkbox" required="required" aria-required="true" id="chbx" name="chbx">

This doesn't seem to solve the trick. Clicking Complete payment still continues even though the checkbox is not checked. Does anybody have an idea how to tell the validator to look at this field too?

Thank you in advance!


Solution

  • The issue happens actually between the version 5.0 and 5.2 dunno where exactly. But if anybody has the same issue, then you need to be sure to use the correct extend (prepend,append) container. There are big differences in the templates between these two versions. My issue was that after updating to 5.2 the box wasn't inside the form anymore. Therefore it wasn't checked for required. I built in a workaround which looks for the version and if equal to or greater 5.2 I put it in different container (I believe it was just one level higher than in 5.0)

    I hope I can help someone with the same issue in the future. JUST LOOK IF YOUR FIELD IS IN A FORM