Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom form cannot remove consent for consent type (adding works) #21

Open
jannisborgers opened this issue Mar 19, 2020 · 0 comments
Open

Comments

@jannisborgers
Copy link

Hi there,

I have a custom form (on the privacy policy page) that allows users to change their consent once they have submitted consent via the banner.

There are two types of consent on the page: Necessary and Statistics, where Necessary cannot be unchecked.

When I only give consent for Necessary cookies, but not statistics. I can set the Statistics consent to true by re-submitting consent via the custom form.

When I try to remove the Statistics consent that I initially gave via the cookie banner, and re-submit the custom form, I get the following error:

Undefined index: cookieTypes
1. in /Users/jannisborgers/Websites/baypat/vendor/nilsenpaul/complete-cookie-consent/src/controllers/ConsentController.php at line 22

Line 22 says:

$checkedCookieTypes = $request->post()['cookieTypes'];

My form template looks like this (I removed some excess mark up here):

<form method="POST" class="ccc-banner__form ccc-form">
            {{ csrfInput() }}
            <input type="hidden" name="action" value="complete-cookie-consent/consent/submit">
                {% set consentInfo = craft.ccc.consentInfo %}
                {% for consentType, consentStatus in consentInfo.consent %}
                    {% set checked = (consentStatus == true or consentType == "necessary") ? "checked" : "" %}
                    {% set disabled = consentType == "necessary" ? "disabled" : "" %}
                    <label for="cookieType-{{ consentType }}" class="ccc-form__label">
                        <input class="cookieForm__label__input" type="checkbox" id="cookieType-{{ consentType }}" name="cookieTypes[]" value="{{ consentType }}" {{ checked }} {{ disabled }} /> 
                        {{ consentType|capitalize }}
                    </label>
                {% endfor %}
                <input type="submit"" value="{{ "Save settings"|t }}">
    </form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant