public function VideoEmbedDialog::ajaxSubmit in Video Embed Field 8.2
Same name and namespace in other branches
- 8 modules/video_embed_wysiwyg/src/Form/VideoEmbedDialog.php \Drupal\video_embed_wysiwyg\Form\VideoEmbedDialog::ajaxSubmit()
An AJAX submit callback to validate the WYSIWYG modal.
File
- modules/
video_embed_wysiwyg/ src/ Form/ VideoEmbedDialog.php, line 173
Class
- VideoEmbedDialog
- A class for a video embed dialog.
Namespace
Drupal\video_embed_wysiwyg\FormCode
public function ajaxSubmit(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
if (!$form_state
->getErrors()) {
// Load the provider and get the information needed for the client.
$provider = $this
->getProvider($form_state
->getValue('video_url'));
$response
->addCommand(new EditorDialogSave($this
->getClientValues($form_state, $provider)));
$response
->addCommand(new CloseModalDialogCommand());
}
else {
unset($form['#prefix'], $form['#suffix']);
$form['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -10,
];
$response
->addCommand(new HtmlCommand(NULL, $form));
}
return $response;
}