public static function ModalForm::create in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/form_api_example/src/Form/ModalForm.php \Drupal\form_api_example\Form\ModalForm::create()
Instantiates a new instance of this class.
This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.
Parameters
\Symfony\Component\DependencyInjection\ContainerInterface $container: The service container this instance should use.
Overrides FormBase::create
File
- form_api_example/
src/ Form/ ModalForm.php, line 29
Class
- ModalForm
- Implements the ModalForm form controller.
Namespace
Drupal\form_api_example\FormCode
public static function create(ContainerInterface $container) {
// Create a new form object and inject its services.
$form = new static();
$form
->setRequestStack($container
->get('request_stack'));
$form
->setStringTranslation($container
->get('string_translation'));
$form
->setMessenger($container
->get('messenger'));
return $form;
}