public function Entity::settingsForm in Display Suite 8.2
Same name and namespace in other branches
- 8.4 src/Plugin/DsField/Entity.php \Drupal\ds\Plugin\DsField\Entity::settingsForm()
- 8.3 src/Plugin/DsField/Entity.php \Drupal\ds\Plugin\DsField\Entity::settingsForm()
The form that holds the settings for this plugin.
Overrides DsFieldBase::settingsForm
File
- src/
Plugin/ DsField/ Entity.php, line 45
Class
- Entity
- Renders an entity by a given view mode.
Namespace
Drupal\ds\Plugin\DsFieldCode
public function settingsForm($form, FormStateInterface $form_state) {
$entity = $this
->linkedEntity();
$view_modes = $this->entityDisplayRepository
->getViewModes($entity);
$options = array();
foreach ($view_modes as $id => $view_mode) {
$options[$id] = $view_mode['label'];
}
$config = $this
->getConfiguration();
$form['entity_view_mode'] = array(
'#type' => 'select',
'#title' => 'View mode',
'#default_value' => $config['entity_view_mode'],
'#options' => $options,
);
return $form;
}