Form submission handler.
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
Overrides FormInterface::submitForm
public function submitForm(array &$form, array &$form_state) {
form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin');
$field = $this->instance
->getField();
$bundles = entity_get_bundles();
$bundle_label = $bundles[$this->instance->entity_type][$this->instance->bundle]['label'];
if ($field && !$field['locked']) {
$this->instance
->delete();
drupal_set_message(t('The field %field has been deleted from the %type content type.', array(
'%field' => $this->instance
->label(),
'%type' => $bundle_label,
)));
}
else {
drupal_set_message(t('There was a problem removing the %field from the %type content type.', array(
'%field' => $this->instance
->label(),
'%type' => $bundle_label,
)), 'error');
}
$admin_path = $this->entityManager
->getAdminPath($this->instance->entity_type, $this->instance->bundle);
$form_state['redirect'] = "{$admin_path}/fields";
// Fields are purged on cron. However field module prevents disabling modules
// when field types they provided are used in a field until it is fully
// purged. In the case that a field has minimal or no content, a single call
// to field_purge_batch() will remove it from the system. Call this with a
// low batch limit to avoid administrators having to wait for cron runs when
// removing instances that meet this criteria.
field_purge_batch(10);
}