function field_form_config_admin_import_form_alter
field_form_config_admin_import_form_alter(&$form, FormStateInterface $form_state)
Implements hook_form_FORM_ID_alter().
Adds a warning if field data will be permanently removed by the configuration synchronization.
See also
\Drupal\field\ConfigImporterFieldPurger
File
- core/modules/field/field.module, line 325
- Attach custom data fields to Drupal entities.
Code
function field_form_config_admin_import_form_alter(&$form, FormStateInterface $form_state) { // Only display the message when there is a storage comparer available and the // form is not submitted. $user_input = $form_state->getUserInput(); $storage_comparer = $form_state->get('storage_comparer'); if ($storage_comparer && empty($user_input)) { $field_storages = ConfigImporterFieldPurger::getFieldStoragesToPurge( $storage_comparer->getSourceStorage()->read('core.extension'), $storage_comparer->getChangelist('delete') ); if ($field_storages) { foreach ($field_storages as $field) { $field_labels[] = $field->label(); } drupal_set_message(\Drupal::translation()->formatPlural( count($field_storages), 'This synchronization will delete data from the field %fields.', 'This synchronization will delete data from the fields: %fields.', array('%fields' => implode(', ', $field_labels)) ), 'warning'); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!field!field.module/function/field_form_config_admin_import_form_alter/8.1.x