public function ViewsEmbedDialog::submitSelectDisplay in Views entity embed 2.0.x
Same name and namespace in other branches
- 8 src/Form/ViewsEmbedDialog.php \Drupal\views_entity_embed\Form\ViewsEmbedDialog::submitSelectDisplay()
Form submission handler for the views selection step.
Return value
\Drupal\Core\Ajax\AjaxResponse The ajax response.
File
- src/
Form/ ViewsEmbedDialog.php, line 290
Class
- ViewsEmbedDialog
- Provides a form to embed URLs.
Namespace
Drupal\views_entity_embed\FormCode
public function submitSelectDisplay(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$view =& $form_state
->get('view');
$display = $form_state
->getValue('select_display');
// 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');
$view_element['data-view-display'] = $display;
$form_state
->set('view_element', $view_element);
$view
->setDisplay($display);
$form_state
->set('step', 'select_arguments');
$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;
}