I'm attempting to make a page for users to edit data for a specific content type, but I only want them to have access to some of the fields not all. To do so I created a custom form display mode for content. I have a custom controller that is meant to display this form with a custom display mode. Here is the code meant to render it.
public function showCustomForm() {
$node = \Drupal::entityTypeManager()->getStorage('node')->load('123');
$edit_form = \Drupal::entityTypeManager()->getFormObject('node', 'my_custom_form_display_mode_id')->setEntity($node);
return \Drupal::formBuilder()->getForm($edit_form);
}
And I get the error
Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "node" entity type did not specify a "my_custom_form_display_mode_id" form class. in Drupal\Core\Entity\EntityTypeManager->getFormObject() (line 184 of /var/www/mydomain/http/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).
I was using this How do I load a form with a specific form display (form mode)? as an example. But still had no luck.
How would I programmatically load a node edit form with a custom form display mode?