1 field_ui.admin.inc | field_ui_view_mode_reset_form($form, &$form_state, $entity_type = NULL, $bundle = NULL, $view_mode_name = NULL) |
Confirm form: Resets a display mode to using the default display.
File
- core/
modules/ field_ui/ field_ui.admin.inc, line 2462 - Admin page callbacks for the Field UI module.
Code
function field_ui_view_mode_reset_form($form, &$form_state, $entity_type = NULL, $bundle = NULL, $view_mode_name = NULL) {
$bundle = field_extract_bundle($entity_type, $bundle);
$form['#entity_type'] = $entity_type;
$form['#machine_name'] = $view_mode_name;
$form['#bundle'] = $bundle;
$view_mode = entity_view_mode_load($entity_type, $view_mode_name);
$path = _field_ui_bundle_admin_path($entity_type, $bundle) . '/display';
$message = '';
// Check to see if this display mode is in use on any other bundles.
$active = array();
$entity_info = entity_get_info($entity_type);
foreach ($entity_info['bundles'] as $machine => $bundle) {
$settings = field_view_mode_settings($entity_type, $machine);
if (isset($settings[$view_mode_name]) && $settings[$view_mode_name]) {
$active[] = t($bundle['label']);
}
}
if (!empty($active)) {
$message .= '<p>' . t('The %view-mode display mode has been customized in the following places:', array('%view-mode' => $view_mode['label'])) . '</p>';
$message .= theme('item_list', array('items' => $active));
}
$message .= '<p>' . t('A reset will cause all customizations to be lost. The <em>Default</em> display mode will be used instead.') . '</p>';
return confirm_form(
$form,
t('Are you sure you want to reset the %view-mode display mode?', array('%view-mode' => $view_mode['label'])),
$path,
$message,
t('Reset'),
t('Cancel')
);
}