Private Message formState storage isn't populated with the members widget data

Created on 13 March 2021, over 3 years ago
Updated 29 January 2024, 10 months ago

It causes the following PHP notice:

Notice: Undefined index: items_count in Drupal\Core\Field\WidgetBase::addMoreSubmit() (line 310 of /var/www/html/core/lib/Drupal/Core/Field/WidgetBase.php)

PrivateMessageForm::buildForm constructs the form display of the private message thread to get the members widget from it.
However it uses clone of the formState object, so the WidgetBase::form can't populate the original form state object with the field widget data.

We can pass the original formstate object or try to fill the storage data manually. I don't like any of it

πŸ› Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine artem_sylchuk Lutsk

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine bohart Lutsk, Ukraine

    Hi @artem_sylchuk,
    Something went wrong on this issue.

    The commit added this line:
    if (empty($storage['field_storage']['#parents']['#fields']['members'])) {

    But variable $storage is always empty (as it is never defined).
    Should we move `$storage = $form_state_copy->getStorage();` above the if or completely remove those lines?

    Thanks!

Production build 0.71.5 2024