diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index f29fc6f..a7f75b8 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -131,9 +131,17 @@ function edit_library_info() { * Implements hook_field_formatter_info_alter(). * * Edit extends the @FieldFormatter annotation with the following keys: - * - edit: I have no idea what this does. Could be 'direct' I think. + * - edit: currently only contains one subkey 'editor' which indicates which + * in-place editor should be used. Possible values are 'form', 'direct' or + * 'disabled'. */ function edit_field_formatter_info_alter(&$info) { + foreach ($info as $formatter_info) { + // Set in-place editor to form if none is supplied. + if (empty($formatter_info['edit'])) { + $formatter_info['edit'] = array('editor' => 'form'); + } + } } /** diff --git a/core/modules/edit/lib/Drupal/edit/EditorSelector.php b/core/modules/edit/lib/Drupal/edit/EditorSelector.php index c42cb02..232a52f 100644 --- a/core/modules/edit/lib/Drupal/edit/EditorSelector.php +++ b/core/modules/edit/lib/Drupal/edit/EditorSelector.php @@ -63,7 +63,7 @@ public function getEditor($formatter_type, FieldInstance $instance, array $items // 'form' editor, since that can work for any field. Formatter definitions // can use 'disabled' to explicitly opt out of in-place editing. $formatter_info = field_info_formatter_types($formatter_type); - $editor_id = isset($formatter_info['edit']['editor']) ? $formatter_info['edit']['editor'] : 'form'; + $editor_id = $formatter_info['edit']['editor']; if ($editor_id === 'disabled') { return; } diff --git a/core/modules/field/lib/Drupal/field/Annotation/FieldFormatter.php b/core/modules/field/lib/Drupal/field/Annotation/FieldFormatter.php index 7fac2bf..f72b2e0 100644 --- a/core/modules/field/lib/Drupal/field/Annotation/FieldFormatter.php +++ b/core/modules/field/lib/Drupal/field/Annotation/FieldFormatter.php @@ -16,6 +16,9 @@ * called by the Field Attach API field_attach_prepare_view() and * field_attach_view() functions. * + * Additional annotation keys form formatters can be defined in + * hook_field_formatter_info_alter(). + * * @Annotation * * @see \Drupal\field\Plugin\Type\Formatter\FormatterPluginManager