public function SearchForm::submitForm in Entity Reference Tree Widget 2.x
Same name and namespace in other branches
- 8 src/Form/SearchForm.php \Drupal\entity_reference_tree\Form\SearchForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ SearchForm.php, line 176
Class
- SearchForm
- ModalForm class.
Namespace
Drupal\entity_reference_tree\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
// If there are any form errors, re-display the form.
if ($form_state
->hasAnyErrors()) {
$response
->addCommand(new ReplaceCommand('#entity_reference_tree_wrapper', $form));
}
else {
$response
->addCommand(new InvokeCommand(NULL, 'entitySearchDialogAjaxCallback', [
$form_state
->getValue('field_id'),
$form_state
->getValue('selected_node'),
]));
$response
->addCommand(new CloseModalDialogCommand());
}
return $response;
}