You are here

public function EditViewsCustomTable::submitForm in Views Custom Table 8

Same name and namespace in other branches
  1. 9.0.x src/Form/EditViewsCustomTable.php \Drupal\view_custom_table\Form\EditViewsCustomTable::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/EditViewsCustomTable.php, line 121

Class

EditViewsCustomTable
Edit views custom table form.

Namespace

Drupal\view_custom_table\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $table_name = $form_state
    ->getValue('table_name');
  $description = $form_state
    ->getValue('description');
  $table_database = $form_state
    ->getValue('table_database');
  $this->configEditable
    ->set($table_name . '.table_name', $table_name)
    ->set($table_name . '.table_database', $table_database)
    ->set($table_name . '.description', $description);
  $result = $this->configEditable
    ->save();
  if ($result) {
    drupal_set_message($this
      ->t('@table is updated.', [
      '@table' => $table_name,
    ]));
  }
  else {
    drupal_set_message($this
      ->t('Could not update @table data, please check log messages for error.', [
      '@table' => $table_name,
    ]), 'error');
  }
  $form_state
    ->setRedirect('view_custom_table.customtable');
}