Problem/Motivation

I am getting following notice:

Notice: Undefined index: data in Drupal\multivaluefield\Plugin\Field\FieldType\MultivaluefieldItem->getValue() (line 326 of modules\multivaluefield\src\Plugin\Field\FieldType\MultivaluefieldItem.php).

Drupal\multivaluefield\Plugin\Field\FieldType\MultivaluefieldItem->getValue() (Line: 41)
Drupal\Core\TypedData\Plugin\DataType\ItemList->getValue() (Line: 121)
Drupal\multivaluefield\Plugin\Field\FieldWidget\MultivaluefieldWidget->formMultipleElements(Object, Array, Object) (Line: 111)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 124)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 532)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 705)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Drupal 9.03
Once I create multifield field I can see that notice, also if I want to modify/edit that field - the same notice.

Proposed resolution

I am not PHP developer, but this works for me and it seems resolved the issue, so please someone check if it is correct syntax:

Line 326:
-if (is_string($value['data'])) {
+if (!empty($value['data']) && (is_string($value['data']))) {

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#6 undefined-index-data-3179752-6.patch576 bytesmkrizaj

Comments

coaston created an issue. See original summary.

coaston’s picture

Issue summary: View changes
coaston’s picture

Status: Active » Needs review
iwsp’s picture

Hi,
Thank you for reporting, I will add the correction for the next version.

coaston’s picture

Assigned: Unassigned » coaston
mkrizaj’s picture

StatusFileSize
new576 bytes

Hi

I've created a patch for this which should be applied to the dev version.

Thanks