You are here

public function FieldDeleteForm::submitForm in Display Suite 8.2

Same name and namespace in other branches
  1. 8.4 src/Form/FieldDeleteForm.php \Drupal\ds\Form\FieldDeleteForm::submitForm()
  2. 8.3 src/Form/FieldDeleteForm.php \Drupal\ds\Form\FieldDeleteForm::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/FieldDeleteForm.php, line 92

Class

FieldDeleteForm
Provides a form to delete a DS field.

Namespace

Drupal\ds\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $field = $this->field;

  // Remove field and clear caches.
  $this
    ->config('ds.field.' . $field['id'])
    ->delete();
  $this->cacheInvalidator
    ->invalidateTags(array(
    'ds_fields_info',
  ));

  // Also clear the ds plugin cache.
  \Drupal::service('plugin.manager.ds')
    ->clearCachedDefinitions();

  // Redirect.
  $url = new Url('ds.fields_list');
  $form_state
    ->setRedirectUrl($url);
  drupal_set_message($this
    ->t('The field @field has been deleted.', array(
    '@field' => $field['label'],
  )));
}