diff --git a/src/Plugin/Field/FieldWidget/MetatagFirehose.php b/src/Plugin/Field/FieldWidget/MetatagFirehose.php index c402730..615f4fb 100644 --- a/src/Plugin/Field/FieldWidget/MetatagFirehose.php +++ b/src/Plugin/Field/FieldWidget/MetatagFirehose.php @@ -52,6 +52,46 @@ class MetatagFirehose extends WidgetBase implements ContainerFactoryPluginInterf $this->metatagManager = $manager; } + /** + * {@inheritdoc} + */ + public static function defaultSettings() { + return [ + 'sidebar' => TRUE, + ] + parent::defaultSettings(); + } + + /** + * {@inheritdoc} + */ + public function settingsForm(array $form, FormStateInterface $form_state) { + $element['sidebar'] = [ + '#type' => 'checkbox', + '#title' => t('Place field in sidebar'), + '#default_value' => $this->getSetting('sidebar'), + '#description' => t('If checked, the field will be placed in the sidebar on entity forms.'), + ]; + + return $element; + } + + /** + * {@inheritdoc} + */ + public function settingsSummary() { + $summary = []; + + $sidebar = $this->getSetting('sidebar'); + if ($sidebar) { + $summary[] = t('Use sidebar: Yes'); + } + else { + $summary[] = t('Use sidebar: No'); + } + + return $summary; + } + /** * {@inheritdoc} */ @@ -93,8 +133,13 @@ class MetatagFirehose extends WidgetBase implements ContainerFactoryPluginInterf $element = $this->metatagManager->form($values, $element, [$entity_type]); } - // Put the form element into the form's "advanced" group. - $element['#group'] = 'advanced'; + // If the "sidebar" option was checked on the field widget, put the + // form element into the form's "advanced" group. Otherwise, let it + // default to the main field area. + $sidebar = $this->getSetting('sidebar'); + if ($sidebar) { + $element['#group'] = 'advanced'; + } return $element; }