protected function EntityBrowserForm::init in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/Form/EntityBrowserForm.php \Drupal\entity_browser\Form\EntityBrowserForm::init()
Initializes form state.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: Form state object.
1 call to EntityBrowserForm::init()
- EntityBrowserForm::buildForm in src/
Form/ EntityBrowserForm.php - Form constructor.
File
- src/
Form/ EntityBrowserForm.php, line 116
Class
- EntityBrowserForm
- The entity browser form.
Namespace
Drupal\entity_browser\FormCode
protected function init(FormStateInterface $form_state) {
// Flag that this form has been initialized.
$form_state
->set('entity_form_initialized', TRUE);
if ($this
->getRequest()->query
->has('uuid')) {
$form_state
->set([
'entity_browser',
'instance_uuid',
], $this
->getRequest()->query
->get('uuid'));
}
else {
$form_state
->set([
'entity_browser',
'instance_uuid',
], $this->uuidGenerator
->generate());
}
$form_state
->set([
'entity_browser',
'selected_entities',
], []);
$form_state
->set([
'entity_browser',
'validators',
], []);
$form_state
->set([
'entity_browser',
'widget_context',
], []);
$form_state
->set([
'entity_browser',
'selection_completed',
], FALSE);
// Initialize form state with persistent data, if present.
if ($storage = $this->selectionStorage
->get($form_state
->get([
'entity_browser',
'instance_uuid',
]))) {
foreach ($storage as $key => $value) {
$form_state
->set([
'entity_browser',
$key,
], $value);
}
}
}