I need to output an existing Commerce Line Item Type field in a custom form and I can do this with a field from a standard Node but can't get it to work with Commerce Line Item types.

The code snippet that works for a Node Article is:

//Get the EntityFormDisplay (i.e. the default Form Display) of this content type
$entity_form_display = \Drupal::service('entity_type.manager')->getStorage('entity_form_display')

I'm trying to modify this to work for a Commerce Line Item type but $entity_form_display is always empty.

I've tried every variation of:

$entity_form_display = \Drupal::service('entity_type.manager')->getStorage('entity_form_display')

But the returned value is always NULL. Any ideas on what the load function is expecting, or is my issue elsewhere?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.