After upgrade to Drupal core 8.0.1 I got long notice when I tried to edit node with field collection color field:

Notice: Undefined index: #required in Drupal\color_field\Plugin\Field\FieldWidget\ColorFieldWidgetDefault->formElement() (line 94 of modules/color_field/src/Plugin/Field/FieldWidget/ColorFieldWidgetDefault.php).

Drupal\color_field\Plugin\Field\FieldWidget\ColorFieldWidgetDefault->formElement(Object, 0, Array, Array, Object)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object)
Drupal\field_collection\Plugin\Field\FieldWidget\FieldCollectionEmbedWidget->formElement(Object, 0, Array, Array, Object)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object)
Drupal\field_collection\Plugin\Field\FieldWidget\FieldCollectionEmbedWidget->formMultipleElements(Object, Array, Object)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object)
Drupal\node\NodeForm->form(Array, Object)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array)
Drupal\Core\Form\FormBuilder->retrieveForm('node_solution_category_edit_form', Object)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

egontinno created an issue. See original summary.

Ivan Zugec’s picture

Status: Active » Needs review
FileSize
589 bytes

Fixed the notice warning.

The $element variable is being passed into the formElement method preloaded with values. However, it's being re-declared as an empty array, i.e., "$element = [];". The attached patch removes "$element = [];" from "formElement"

Status: Needs review » Needs work

The last submitted patch, 2: fixed-notice-2642712-2.patch, failed testing.

The last submitted patch, 2: fixed-notice-2642712-2.patch, failed testing.

kasperg’s picture

Status: Needs work » Reviewed & tested by the community

#2 works and looks like the right solution to me.

There are no tests for this module. I guess that is causing testbot to fail.

jackbravo’s picture

Yes, works for me too.

dabbor’s picture

Just letting you know, it works for me too.

Thanks Ivan ;)

Christophe Bourgois’s picture

#2 worked for me also

  • targoo committed b9ffa90 on 8.x-2.x authored by Ivan Zugec
    Issue #2642712 by Ivan Zugec: Notice: Undefined index: #required
    
targoo’s picture

Merge to dev. Thanks for the patch.

targoo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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