- Issue created by @jaypan
- πΊπΈUnited States apmsooner
Is there anything else u can provide to help me reproduce? Drupal version, anything particular about the setup with the form? Layout builder or paragraphs in the mix?
- π¨π¦Canada jaypan Victoria, BC
I figured out the problem. I was extending CustomFlexWidget to create a custom widget, and I had extended the create() function. I was setting $instance->customFieldManager in 3.1.7, I needed to change this to $instance->customFieldTypeManager in 3.1.8, as it appears the property name changed between versions.
- π¨π¦Canada jaypan Victoria, BC
A way to prevent this type of issue in the future, would be to remove the call to create() altogether, and then add functions to retrieve the managers that initialize them before returning them. So you can add these getters:
<?php
public function getCustomFieldTypeManager() {
if (!isset($this->customFieldTypeManager)) {
$this->customFieldTypeManager = \Drupal::service('plugin.manager.custom_field_type');
}return $this->customFieldTypeManager;
}public function getCustomFieldWidgetManager() {
if (!isset($this->customFieldWidgetManager)) {
$this->customFieldWidgetManager = \Drupal::service('plugin.manager.custom_field_widget');
}return $this->customFieldWidgetManager;
}Then change instances of
$this->customFieldTypeManager
to$this->getCustomFieldTypeManager()
and$this->customFieldWidgetManager
to$this->getCustomFieldWidgetManager()
. This way, if you change the property names in the future, classes that extend your class will not be affected.