Unable to save settings form

Created on 16 January 2024, 11 months ago
Updated 26 January 2024, 11 months ago

Problem/Motivation

Unable to save settings form. Using Chrome Version 120.0.6099.216 (Official Build) (x86_64). Also attempted using Safari as well, same issue and errors.

Console reports these errors:

An invalid form control with name='save_preferences_button_label' is not focusable. 
<input data-drupal-selector="edit-save-preferences-button-label" type="text" id="edit-save-preferences-button-label" name="save_preferences_button_label" value="" size="60" maxlength="128" class="form-text form-element form-element--type-text form-element--api-textfield" data-drupal-states="{&quot;visible&quot;:{&quot;input[name=\u0027enable_save_preferences_button\u0027]&quot;:{&quot;checked&quot;:true}},&quot;required&quot;:{&quot;input[name=\u0027enable_save_preferences_button\u0027]&quot;:{&quot;checked&quot;:true}}}" required="required" aria-required="true">


An invalid form control with name='accept_all_categories_button_label' is not focusable. <input data-drupal-selector=​"edit-accept-all-categories-button-label" type=​"text" id=​"edit-accept-all-categories-button-label" name=​"accept_all_categories_button_label" value size=​"60" maxlength=​"128" class=​"form-text form-element form-element--type-text form-element--api-textfield" data-drupal-states=​"{&quot;visible&quot;:​{&quot;input[name=\u0027enable_save_preferences_button\u0027]​&quot;:​{&quot;checked&quot;:​true}​}​,&quot;required&quot;:​{&quot;input[name=\u0027enable_save_preferences_button\u0027]​&quot;:​{&quot;checked&quot;:​true}​}​}​" required=​"required" aria-required=​"true">​#shadow-root (user-agent)</input>​
14:25:49.064 settings:1 An invalid form control

Steps to reproduce

Screen capture of error Screen cap [https://drive.google.com/file/d/1nI9LvROgBvIoiVOg2crB3gWgyqgroyFS/view?u...

🐛 Bug report
Status

Active

Version

1.24

Component

Code

Created by

🇺🇸United States travelertt Cincinnati

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @travelertt
  • 🇧🇷Brazil irafah

    I can confirm this issue is also happening to me when I try to save the settings.
    The same steps to reproduce the error.

  • 🇧🇷Brazil irafah

    The reason why this issue happens is because of the "Replace the Agree button with "Save preferences" and "Accept all categories" buttons." that is checked by default, which makes the other two fields ("Save preferences" and "Accept all categories") to be required.

    If you check the code at EuCookieComplianceConfigForm.php#L274, you will see that the default value comes from the config, and, for some reason, it is set as TRUE even before it is visible.

    '#default_value' => $config->get('enable_save_preferences_button')

    I tested something like !empty($config->get('enable_save_preferences_button')) ? $config->get('enable_save_preferences_button') : FALSE,, but it didn't work.
    Perhaps because there's something set in enable_save_preferences_button, and it is considered "TRUE".

    I'm having some issues with my Xdebug, so, that's why I haven't had a chance to check it properly.
    In case anyone can check that before me and make the necessary changes to make the field default to FALSE unless TRUE has been properly set, that would be fab.

    Thanks!

  • 🇧🇷Brazil irafah

    Hello! I investigated this issue and I noticed that enable_save_preferences_button (Cookies categories section) is set as TRUE in a couple of places. Why is that?

    I think this field should be set as FALSE considering that the default value for the "Consent method" is "Opt-in" not Opt-in with categories (which is the one that makes the Cookies categories visible)

    Otherwise, we will have this issue when configuring the module for the first time, as there are two mandatory fields hidden.
    If you are not using the "Opt-in with categories" option, a workaround is to manually check "Opt-in with categories", uncheck Replace the Agree button with "Save preferences" and "Accept all categories" buttons, then choose the option you want and configure as usual.

    Some places where I found it:

    eu_cookie_compliance.settings.yml#L63
    eu_cookie_compliance.install#L454
    EuCookieComplianceMigrateTest.php#L45
Production build 0.71.5 2024