I'm trying to create the form from Entity in the controller.
This is the code of controller:
class OutOfOfficeController extends ControllerBase
{
/**
* @return array
*/
public function add()
{
$event = $this->entityTypeManager()->getStorage('event')->create(['type' => 'out_of_office']);
$form = $this->entityFormBuilder()->getForm($event);
return $form;
}
}
And this is the error which I get:
Error: Call to a member function getTranslationFromContext() on null in Drupal\Core\Entity\ContentEntityForm->initFormLangcodes() (line 313 of core/lib/Drupal/Core/Entity/ContentEntityForm.php).
- It seems that the ContentEntityForm do not have any dependencies
- In ContentEntityForm the
$this->entityRepository
returnsnull
.
Am I missing something?