Problem/Motivation
After updating all drupal modules in a website that already had colorapi and jquery_colorpicker enabled, and already had a color field with the jquery_colorpicker widget, editing or creating nodes with a color field now throw this error:
Notice: Undefined index: name in Drupal\colorapi\Plugin\Field\FieldType\ColorItem->setValue() (line 85 of modules/contrib/colorapi/src/Plugin/Field/FieldType/ColorItem.php).
Steps to reproduce
somehow have a website with a node type with a color field, created with a previous version of colorapi and jquery_colorpicker.
Then update all modules and run updb and add or edit a node that has a color field. It is not even necessary to have the field widget set to jquery_colorpicker, just having the widget set to 'Textfield Input' also generates the same error
Proposed resolution
- Edit colorapi/src/Plugin/Field/FieldType/ColorItem.php
- Add new line inside function setValue (line 90) to check if $values['name'] exists:
$values['name'] = isset($values['name']) ? $values['name'] : '';
Remaining tasks
- someone else confirms bug (had it myself in 3 different projects)
- create/test patch
- commit patch
- or just immediatly add the line above in code in a newer version of the module
Comment | File | Size | Author |
---|---|---|---|
#4 | 3175130-4.patch | 674 bytes | Neslee Canil Pinto |
#3 | colorapi-undefined-index-name-3175130-1.patch | 1.08 KB | flyke |
Comments
Comment #2
flyke CreditAttribution: flyke commentedComment #3
flyke CreditAttribution: flyke commentedComment #4
Neslee Canil PintoComment #7
Neslee Canil Pinto