To reproduce:

1. create a link type field, set it to internal only, not required.
2. create a link type field, set it to external only, not required.
3. create a list (integer) field, required with the following options:

1|Internal
2|External

4. Add field states on the two link fields, visible based on the value of the list field.

If you leave the link fields empty and save the node, you'll see the following notice repeated:

Notice: Undefined index: uri in Drupal\link\Plugin\Field\FieldWidget\LinkWidget->massageFormValues() (line 335 of core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php).
Drupal\link\Plugin\Field\FieldWidget\LinkWidget->massageFormValues(Array, Array, Object) (Line: 376)
Drupal\Core\Field\WidgetBase->extractFormValues(Object, Array, Object) (Line: 222)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object, Array, Object) (Line: 326)
Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 293)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 147)
Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object) (Line: 278)
Drupal\Core\Entity\EntityForm->submitForm(Array, Object) (Line: 137)
Drupal\Core\Entity\ContentEntityForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('node_page_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_page_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
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}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Removing the field states ui configuration on the two link fields suppresses the notices.

I'll see if I can come up with a patch for this.

Comments

slydevil created an issue. See original summary.

slydevil’s picture

Priority: Minor » Major

It turns out that if you try to add a value to either link field, the value is not saved. Bumping to major because of this.

slydevil’s picture

It could be that the link field type has not been defined...I'll start there.

slydevil’s picture

Title: Notices when saving empty link fields » link type field Support
Category: Bug report » Feature request
slydevil’s picture

Status: Active » Needs review

Patch created under #2937114

candilw’s picture

I am getting the same issue on File and Image types.

nickdickinsonwilde’s picture

nickdickinsonwilde’s picture

Assigned: slydevil » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.