function paragraphs_form_entity_form_display_edit_form_alter

Implements hook_form_FORM_ID_alter().

File

paragraphs/paragraphs.module, line 114
Contains paragraphs.module

Code

function paragraphs_form_entity_form_display_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $field_definitions = \Drupal::service('entity_field.manager')
    ->getFieldDefinitions($form['#entity_type'], $form['#bundle']);

  // Loop over ERR field's display options with paragraph target type.
  foreach (array_keys($field_definitions) as $field_name) {
    if ($field_definitions[$field_name]
      ->getType() == 'entity_reference_revisions') {
      if ($field_definitions[$field_name]
        ->getSettings()['target_type'] == 'paragraph') {
        foreach ([
          'options_buttons',
          'options_select',
          'entity_reference_revisions_autocomplete',
        ] as $option) {
          unset($form['fields'][$field_name]['plugin']['type']['#options'][$option]);
        }
      }
    }
  }
}