function ds_extras_form_ds_admin_form_alter in Display Suite 8.2
Same name and namespace in other branches
- 8.4 modules/ds_extras/ds_extras.module \ds_extras_form_ds_admin_form_alter()
- 8.3 modules/ds_extras/ds_extras.module \ds_extras_form_ds_admin_form_alter()
Implements hook_form_FORM_ID_alter().
File
- modules/
ds_extras/ ds_extras.module, line 199 - Display Suite extras main functions.
Code
function ds_extras_form_ds_admin_form_alter(&$form, FormStateInterface $form_state) {
$config = \Drupal::configFactory()
->getEditable('ds_extras.settings');
$form['fs2'] = array(
'#type' => 'details',
'#title' => t('Extra fields'),
'#group' => 'additional_settings',
'#weight' => 2,
'#tree' => TRUE,
);
$form['fs2']['fields_extra'] = array(
'#type' => 'checkbox',
'#title' => t('Enable extra fields'),
'#description' => t('Make fields from other modules available on the "Manage display" screens.'),
'#default_value' => $config
->get('fields_extra'),
);
$form['fs2']['fields_extra_list'] = array(
'#type' => 'textarea',
'#description' => t('Enter fields line by line, where each line is a combination of entity type, bundle and field name. E.g. node|article|tweetbutton. It might be possible that the actual content of the field depends on configuration of that field/module.'),
'#default_value' => implode("\n", $config
->get('fields_extra_list')),
'#states' => array(
'visible' => array(
'input[name="fs2[fields_extra]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['fs3']['field_permissions'] = array(
'#type' => 'checkbox',
'#title' => t('Field permissions'),
'#description' => t('Enables view permissions on all Display Suite fields.'),
'#default_value' => $config
->get('field_permissions'),
);
if (\Drupal::moduleHandler()
->moduleExists('block')) {
$url = Url::fromUri('https://www.drupal.org/node/2754967');
$link = Drupal::l(t('handbook page'), $url);
$form['fs3']['region_to_block'] = array(
'#type' => 'checkbox',
'#title' => t('Region to block (deprecated)'),
'#description' => t('Create additional regions exposed as block. Note: this will not work on the default view mode.') . '<br/>' . '<b>' . t('This functionality is not compatible with some caching modules. Read the @handbook for a better alternative.', array(
'@handbook' => $link,
)) . '</b>',
'#default_value' => $config
->get('region_to_block'),
);
}
$form['fs3']['switch_field'] = array(
'#type' => 'checkbox',
'#title' => t('View mode switcher'),
'#description' => t('Adds a field with links to switch view modes inline with Ajax. Only works for nodes at this time. It does not work in combination with the reset layout.'),
'#default_value' => $config
->get('switch_field'),
);
$form['fs3']['hidden_region'] = array(
'#type' => 'checkbox',
'#title' => t('Hidden region'),
'#description' => t('Add a hidden region to the layouts. Fields will be built but not printed.'),
'#default_value' => $config
->get('hidden_region'),
);
$form['fs3']['override_node_revision'] = array(
'#type' => 'checkbox',
'#title' => t('Custom node revision view mode'),
'#description' => t('Override the node revision page view with a custom view mode'),
'#default_value' => $config
->get('override_node_revision'),
);
$options = array();
$view_modes = \Drupal::service('entity_display.repository')
->getViewModes('node');
foreach ($view_modes as $key => $view_mode) {
$options[$key] = $view_mode['label'];
}
$form['fs3']['override_node_revision_view_mode'] = array(
'#type' => 'select',
'#description' => t('The revision view mode'),
'#default_value' => $config
->get('override_node_revision_view_mode'),
'#options' => $options,
'#states' => array(
'visible' => array(
'input[name="fs3[override_node_revision]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['#submit'][] = 'ds_extras_settings_submit';
$form['#attached']['library'][] = 'ds_extras/admin';
}