Unable to update a scheduled record

Created on 26 November 2024, 27 days ago

Problem/Motivation

Was working before until after upgraded to core 10.3.*
Unable to update a scheduled item, it gives error "All fields need to be filled".

Error log show below:
Warning: Undefined array key "wrapper" in Drupal\scheduled_publish\Plugin\Field\FieldWidget\ScheduledPublishWidget::validateElement() (line 494

Checked code, indeed the wrapper attribute does not exist.

Steps to reproduce

Try to update an existing scheduled record. It says "All fields need to be filled"

🐛 Bug report
Status

Active

Version

4.0

Component

User interface

Created by

🇲🇾Malaysia elaine.ong

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

Merge Requests

Comments & Activities

  • Issue created by @elaine.ong
  • Pipeline finished with Success
    27 days ago
    Total: 170s
    #350515
  • 🇮🇳India vinayakmk47

    The issue was caused by the wrapper key being accessed without ensuring its existence in the field value, resulting in a "Undefined array key" error during form validation.

    I updated the validateElement() method to use null coalescing (??) to check if the wrapper key exists before accessing it. If the wrapper key is not present, the logic now defaults to handling the field's value directly. This ensures robust validation and prevents runtime errors.

    The changes involve validating the structure of $form_state->getValue() and avoiding assumptions about the presence of the wrapper key in the datetime field.

    I tested the fix by creating and updating scheduled records. The form now works as expected without errors. Both valid and invalid inputs are handled correctly, and the error messages display as intended.

    Please review the changes and let me know if any additional adjustments are required. I'm happy to make further improvements if needed.

  • 🇲🇾Malaysia elaine.ong

    Thanks. Tested good.

  • 🇲🇾Malaysia elaine.ong

    Hi @vinayakmk47 May I know what is the next step to get the fix deployed?

  • 🇧🇪Belgium revagomes

    Updating issue status to Reviewed & Tested.

Production build 0.71.5 2024