Ignore configurability of fields (because not all fields have this property).
1 unresolved thread
Closes #3467817
Merge request reports
Activity
323 333 */ 324 334 protected function getFieldDefinitions() { 335 // Override parent method: do not filter field definitions, all fields' 336 // display is configurable. 325 337 if (!isset($this->fieldDefinitions)) { 326 $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->targetEntityType, $this->bundle); 327 328 $this->fieldDefinitions = $definitions; 329 foreach ($this->fieldDefinitions as $field_definition) { 330 if ($field_definition instanceof BaseFieldDefinition || $field_definition instanceof FieldDefinition) { 331 // We'd like to be able to configure all the fields thus override 332 // displayConfigurable to true for all field definitions. 333 $field_definition->setDisplayConfigurable($this->displayContext, TRUE); 334 } 335 } 338 $this->fieldDefinitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->targetEntityType, $this->bundle); Cause of bug:
During save, EntityDisplayBase::toArray() (the parent class) keeps the 'hidden' property set for any field that isn't "configurable". Non-fieldAPI fields like title are not set to be "configurable".
Challenge:
- EntityCeDisplay::getFieldDefinitions() changes most field definitions to be configurable.
- The title field has no setDisplayConfigurable() method to do this: it is not a FieldConfig or BaseFieldDefinition object, but a FieldDefinitionOverride object.
Also, IMHO it is not ideal to have to change those definitions.
Fix: instead,
- Override EntityCeDisplay::toArray() to not call parent EntityDisplayBase::toArray(), only grandparent ConfigEntityBase::toArray()
- Simplify EntityCeDisplay::getFieldDefinitions() to not make anything configurable anymore. From now on, we will/must ignore a field definition's isDisplayConfigurable(). Note: current callers (there is only one) are not affected by this change.
Please register or sign in to reply