public function FieldDeleteForm::submitForm in Display Suite 8.4
Same name and namespace in other branches
- 8.2 src/Form/FieldDeleteForm.php \Drupal\ds\Form\FieldDeleteForm::submitForm()
- 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\FormCode
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([
'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);
$this
->messenger()
->addMessage($this
->t('The field @field has been deleted.', [
'@field' => $field['label'],
]));
}