Try to remove entry but remove button not work

Created on 16 October 2023, about 1 year ago
Updated 24 October 2023, about 1 year ago

Problem/Motivation

When there is single entry maintained at the backend of switch page theme page: admin/config/system/switch_page_theme then remove button not work

Steps to reproduce

1. I have adedd ONLY One entry here: /admin/config/system/switch_page_theme

2. Then try to remove the entry : by click on remove button
Error maintained in the logs:

TypeError: Cannot access offset of type string on string in Drupal\switch_page_theme\Form\SwitchPageThemeSettingForm- 
    >buildForm() (line 198 of /var/www/html/web/modules/contrib/switch_page_theme/src/Form/SwitchPageThemeSettingForm.php)

3. Then try to remove the entry/page name from the "pages" column & try to click on save button

but HTML validation throws : pages field required

Proposed resolution

If "Enabled" checkbox is unchecked by user for particular entry then "pages" field should not require in-case of if only single entry in the list,

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

4.0

Component

User interface

Created by

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

Comments & Activities

  • Issue created by @pooja_sharma
  • First commit to issue fork.
  • @shiv_yadav opened merge request.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India shiv_yadav

    Hello Pooja , i have fixed this issue. created MR.
    please review & retest it.
    Thanks.

  • Status changed to Needs work about 1 year ago
  • While testing code after applying mentioned changes , issue is not fixed

  • 🇮🇳India shiv_yadav

    Hello pooja, I have not got any error. remove button working fine for me.

  • This issue is not fixed
    If "Enabled" checkbox is unchecked by user for particular entry then "pages" field should not require and should able to save the form

    See the attachment & I removed the value from "pages" column, still validation throws on pages field column require not letting me save the form.

  • 🇮🇳India mukhtarm

    I think after the patch, it's working as expected. Thanks @@shiv_yadav

    Although, there are tweaks can be applied to the workflow i think:

    1) If there is only one entry, first clicking on Remove it will clear the item in the form only (Instead it can be directly do the step 2 i think, if there is only one entry). Then on submitting the form it won't allow because we have to enter the pages :). This is a legitimate validation.

    2) Again clicking on the Remove button after step 1 without saving, it will remove the entry completely and will show a message :

    "There are no items yet. Add an item."

    And then saving the form will give you a fresh entry form.

Production build 0.71.5 2024