function quickedit_field_formatter_info_alter

Same name and namespace in other branches
  1. 8.9.x core/modules/quickedit/quickedit.module \quickedit_field_formatter_info_alter()

Implements hook_field_formatter_info_alter().

Quick Edit extends the @FieldFormatter annotation with the following keys:

  • quickedit: currently only contains one subkey 'editor' which indicates which in-place editor should be used. Possible values are 'form', 'plain_text', 'disabled' or another in-place editor other than the ones Quick Edit module provides.

File

core/modules/quickedit/quickedit.module, line 119

Code

function quickedit_field_formatter_info_alter(&$info) {
    foreach ($info as $key => $settings) {
        // Set in-place editor to 'form' if none is supplied.
        if (empty($settings['quickedit'])) {
            $info[$key]['quickedit'] = [
                'editor' => 'form',
            ];
        }
    }
    $info['basic_string']['quickedit'] = [
        'editor' => 'plain_text',
    ];
    $info['string']['quickedit'] = [
        'editor' => 'plain_text',
    ];
    // Update \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter's
    // annotation to indicate that it supports the 'editor' in-place editor
    // provided by this module, if enabled.
    if (\Drupal::moduleHandler()->moduleExists('editor')) {
        $info['text_default']['quickedit'] = [
            'editor' => 'editor',
        ];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.