You are here

public function ViewTemplateForm::submitForm in Views Templates 8

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/ViewTemplateForm.php, line 44

Class

ViewTemplateForm
Form controller for the view template entity add forms.

Namespace

Drupal\views_templates

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $builder = $this
    ->createBuilder($form_state
    ->getValue('builder_id'));
  $values = $form_state
    ->cleanValues()
    ->getValues();
  $view = $builder
    ->createView($values);
  $view
    ->save();

  // Redirect the user to the view admin form.
  $form_state
    ->setRedirectUrl($view
    ->toUrl('edit-form'));
}