public function SwitchField::settingsForm in Display Suite 8.2
Same name and namespace in other branches
- 8.4 modules/ds_extras/src/Plugin/DsField/SwitchField.php \Drupal\ds_extras\Plugin\DsField\SwitchField::settingsForm()
- 8.3 modules/ds_extras/src/Plugin/DsField/SwitchField.php \Drupal\ds_extras\Plugin\DsField\SwitchField::settingsForm()
The form that holds the settings for this plugin.
Overrides DsFieldBase::settingsForm
File
- modules/
ds_extras/ src/ Plugin/ DsField/ SwitchField.php, line 110
Class
- SwitchField
- Plugin that generates a link to switch view mode with via ajax.
Namespace
Drupal\ds_extras\Plugin\DsFieldCode
public function settingsForm($form, FormStateInterface $form_state) {
$entity_type = $this
->getEntityTypeId();
$bundle = $this
->bundle();
$view_modes = $this->entityDisplayRepository
->getViewModes($entity_type);
$form['info'] = array(
'#markup' => $this
->t('Enter a label for the link for the view modes you want to switch to.<br />Leave empty to hide link. They will be localized.'),
);
$config = $this
->getConfiguration();
$config = isset($config['vms']) ? $config['vms'] : array();
foreach ($view_modes as $key => $value) {
$entity_display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $key);
if (!empty($entity_display)) {
if ($entity_display
->status()) {
$form['vms'][$key] = array(
'#type' => 'textfield',
'#default_value' => isset($config[$key]) ? $config[$key] : '',
'#size' => 20,
'#title' => Html::escape($value['label']),
);
}
}
}
return $form;
}