Cannot set Displays for view or form modes

Created on 8 February 2023, almost 2 years ago
Updated 9 February 2023, almost 2 years ago

Problem/Motivation

If I provide a "displays" key I getting this error

Call to a member function getRenderer() on null in Drupal\field_create\FieldCreateManager->setDisplay() (line 313 of /xxx/web/modules/contrib/field_create/src/FieldCreateManager.php) #0 /xxx/web/modules/contrib/field_create/src/FieldCreateManager.php(234): Drupal\field_create\FieldCreateManager->setDisplay('view', Object(Drupal\field\Entity\FieldConfig), 'field_icon', 'taxonomy_term', 'actiontypes', 'teaser', Array)

Looking at that line, I see that

$storage->load($entity_type_id . '.' . $bundle_id . '.' . $view_mode_id)

is null but those variables are looking to be correct (ex. "taxonomy_term.actiontypes.default").

I did this hack of a fix -

$component = empty($storage->load($key)) ? false : $storage->load($key)->getRenderer($field_name);

-
but then just got another error `Call to a member function getConfigDependencyName() on null`

Steps to reproduce

using json below:

{
    "taxonomy_term": {
        "icon": {
            "name": "icon",
            "label": "Icon",
            "type": "image",
            "force": true,
            "bundles": {
                "actiontypes": {
                    "displays": {
                        "form": {
                            "default": {
                                "region": "content",
                                "hidden": {
                                    "links": true,
                                    "created": true,
                                    "path": true,
                                    "promote": true,
                                    "status": true,
                                    "sticky": true,
                                    "uid": true
                                }
                            }
                        },
                        "view": {
                            "default": {
                                "label": "above"
                            },
                            "teaser": {
                                "label": "above"
                            }
                        }
                    }
                }
            },
            "cardinality": 1,
            "dependencies": {
                "module": "taxonomy_term",
                "config": []
            },
            "settings": {
                "alt_field": true,
                "alt_field_required": false,
                "title_field": true,
                "title_field_required": false,
                "max_resolution": "",
                "min_resolution": "",
                "default_image": {
                    "uuid": null,
                    "alt": "",
                    "title": "",
                    "width": null,
                    "height": null
                },
                "file_directory": "[date:custom:Y]-[date:custom:m]",
                "file_extensions": "png gif jpg jpeg svg",
                "max_filesize": "",
                "handler": "default:file",
                "handler_settings": [],
                "target_type": "file",
                "display_field": true,
                "display_default": true,
                "uri_scheme": "public",
                "field_required": false
            },
            "entity_type": "taxonomy_term"
        },
        "data_type": {
            "name": "data_type",
            "label": "Data Type",
            "type": "list_string",
            "force": true,
            "bundles": {
                "actiontypes": {
                    "displays": {
                        "form": {
                            "default": {
                                "region": "content",
                                "hidden": {
                                    "links": true,
                                    "created": true,
                                    "path": true,
                                    "promote": true,
                                    "status": true,
                                    "sticky": true,
                                    "uid": true
                                }
                            }
                        },
                        "view": {
                            "default": {
                                "label": "above"
                            },
                            "teaser": {
                                "label": "above"
                            }
                        }
                    }
                }
            },
            "cardinality": 1,
            "dependencies": {
                "module": "taxonomy_term",
                "config": []
            },
            "settings": {
                "field_required": true,
                "allowed_values": [
                    {
                        "value": "number",
                        "label": "number"
                    },
                    {
                        "value": "string",
                        "label": "string"
                    }
                ],
                "default": "string"
            },
            "default_value": "string",
            "entity_type": "taxonomy_term"
        }
    }
    }
}
πŸ› Bug report
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States taylormade415

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024