public function Entity::settingsForm in Display Suite 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/DsField/Entity.php \Drupal\ds\Plugin\DsField\Entity::settingsForm()
- 8.2 src/Plugin/DsField/Entity.php \Drupal\ds\Plugin\DsField\Entity::settingsForm()
The form that holds the settings for this plugin.
Parameters
array $form: The form definition array for the field configuration form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The renderable form array representing the entire configuration form.
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 = [];
foreach ($view_modes as $id => $view_mode) {
$options[$id] = $view_mode['label'];
}
$config = $this
->getConfiguration();
$form['entity_view_mode'] = [
'#type' => 'select',
'#title' => 'View mode',
'#default_value' => $config['entity_view_mode'],
'#options' => $options,
];
return $form;
}