public function ViewsEmbedDialog::submitSelectViewStep in Views entity embed 8
Same name and namespace in other branches
- 2.0.x src/Form/ViewsEmbedDialog.php \Drupal\views_entity_embed\Form\ViewsEmbedDialog::submitSelectViewStep()
Form submission handler for the views selection step.
Return value
\Drupal\Core\Ajax\AjaxResponse The ajax response.
File
- src/
Form/ ViewsEmbedDialog.php, line 181
Class
- ViewsEmbedDialog
- Provides a form to embed URLs.
Namespace
Drupal\views_entity_embed\FormCode
public function submitSelectViewStep(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
// Display errors in form, if any.
if ($form_state
->hasAnyErrors()) {
unset($form['#prefix'], $form['#suffix']);
$form['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -10,
];
$response
->addCommand(new HtmlCommand('#views-entity-embed-dialog-form', $form));
}
else {
$view_element = $form_state
->get('view_element');
// Add data-view-name with selected view_name.
$view_element['data-view-name'] = $form_state
->getValue('view_name');
$form_state
->set('view_element', $view_element);
$form_state
->set('step', 'select_display');
$form_state
->set('view', Views::getView($form_state
->getValue('view_name')));
$form_state
->setRebuild(TRUE);
$rebuild_form = $this->formBuilder
->rebuildForm('views_entity_embed_dialog', $form_state, $form);
unset($rebuild_form['#prefix'], $rebuild_form['#suffix']);
$response
->addCommand(new HtmlCommand('#views-entity-embed-dialog-form', $rebuild_form));
$response
->addCommand(new SetDialogTitleCommand('', $rebuild_form['#title']));
}
return $response;
}