The custom add more button labels aren't saved

Created on 2 January 2024, 12 months ago
Updated 22 February 2024, 10 months ago

Problem/Motivation

This module works perfectly fine in Drupal 9 but not working anymore in Drupal 10.2.0, the Custom add another item button and Custom remove button labels are not saved in the field config.

Steps to reproduce

- Install this module in a Drupal 10.2.0 site.
- Add a multiple values field
- Add the Custom add another item button and Custom remove button labels
- Save
- Edit the new created field again, the labels are not saved.

Proposed resolution

I don't have solution yet but looking at custom_add_another_form_field_storage_config_edit_form_alter function, there is no actions key in the form that leads to this issue https://www.drupal.org/project/custom_add_another/issues/3411400 🐛 TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in array_unshift() Needs review

Applied the suggestion in this MR https://git.drupalcode.org/project/custom_add_another/-/merge_requests/4 but still not working.

🐛 Bug report
Status

Needs work

Version

2.1

Component

Code

Created by

🇺🇸United States hungdo

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

  • Issue created by @hungdo
  • 🇹🇭Thailand Nick Hope

    I confirm this in 2.0.0-beta1 in D10.2.1 with PHP 8.3. I tested a media item form and with a taxonomy term form.

    Only new buttons are affected. Existing custom add and remove buttons still display correctly.

    Neither #2 nor #4 at https://www.drupal.org/project/custom_add_another/issues/3411400 🐛 TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in array_unshift() Needs review help fix this.

    I don't believe the issue meets the requirements for critical status , but obviously it's useless going forward.

  • 🇬🇧United Kingdom steven jones

    Will take a look asap.

    • Steven Jones committed 19961f40 on 2.x
      Issue #3411964: Fix our version constraint to working versions of Drupal...
    • Steven Jones committed c5cb9601 on 2.x
      Issue #3411964 by Steven Jones: The custom add more button labels aren't...
  • Status changed to Fixed 12 months ago
  • 🇬🇧United Kingdom steven jones

    Fixed in 2.x, will cut a release shortly.

  • Status changed to Needs work 12 months ago
  • 🇹🇭Thailand Nick Hope

    Thanks for the new releases, but unfortunately I've still got the same problem with 2.1.0-beta1 in D10.2.1 with PHP 8.3.1. The labels are not saved.

  • 🇬🇧United Kingdom steven jones

    @Nick Hope are you sure you've rebuilt caches etc?

  • 🇹🇭Thailand Nick Hope

    I've done further testing. Sites are both D10.2.1 with PHP 8.3.0. These were the steps. Unexpected results are in bold...

    On near-vanilla test site:

    1. composer require 'drupal/custom_add_another:^2.1@beta'
    2. drush en custom_add_another
    3. drush updb
    4. drush cr
    5. Add new plain text field to basic page content type.
    6. Set to unlimited.
    7. Set custom add button text "Add another thing".
    8. Set custom remove button "Remove thing".
    9. Save
    10. Edit
    11. Add button displays custom text "Add another thing".
    12. Remove button displays standard text "Remove".
    13. Edit the field in the basic page content type.
    14. Both custom button fields still contain the custom text.

    On a complex development site (with very long history):

    1. Delete module
    2. "drupal/custom_add_another": "^2.1@beta",
    3. drush cr
    4. Clear all caches in browser too (Admin Toolbar).
    5. Add new plain text field to basic page content type.
    6. Set to unlimited.
    7. Set custom add button text "Add another thing".
    8. Set custom remove button "Remove thing".
    9. Save
    10. Edit
    11. Add button displays standard text "Add another item".
    12. Remove button displays standard text "Remove".
    13. Edit the field in the basic page content type.
    14. Both custom button fields are empty.
    15. Repeat steps, adding unlimited plain text field to audio file media type. Same result.
    16. Added custom remove text to a taxonomy term field that already had custom add text (from a long time ago). After saving, both the custom add text and custom remove text in that field config were empty.

    I'll try and do more testing with older versions of PHP / Drupal / CAA to try and narrow down the problem. Maybe I'll also see if values stick if I manually edit the database.

  • 🇮🇳India junaidpv Kannur, Kerala

    I am facing same issue as the scenario 1 given in comment #11. Rebuilding the cache did not help.

Production build 0.71.5 2024