Keycloak Custom Registration Template Checkbox Value is not persisted

Hello, I am trying to add 2 checkboxes to my custom registration template. They are rendered properly and I can check and uncheck the checkboxes but even if they are both checked, the attribute values on the users attribute table for the checkboxes will be empty after the registration was completed. Any ideas on what I am doing wrong here ?

                <div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('emailSubscription',properties.kcFormGroupErrorClass!)}">
                    <div class="${properties.kcInputWrapperClass!}">
                        <input
                        required
                        type="checkbox"
                        id="user.attributes.emailSubscription"
                        name="user.attributes.emailSubscription"
                        value="${(register.formData['user.attributes.emailSubscription']!'')}"
                        />
                        <label for="user.attributes.emailSubscription">${msg("emailSubscriptionText")}</label>
                    </div>
                </div>

PS: I already added several other input elements like selects and normal inputs and all work like charm.

I could think of an workaround by writing some javascript and add two hidden normal input fields where I assign the values to when the user clicks the checkboxes, but I would prefer to avoid hacky workarounds like this. :^)

Thanks in advance,
Greetings
dmeStudent