You are here

function conflict_paragraphs_form_alter in Conflict 8.2

Implements hook_form_alter().

Unset the conflict resolution of a paragraph field as whole set by the conflict resolution of the parent entity. We use conflict resolution on field item level instead.

File

modules/conflict_paragraphs/conflict_paragraphs.module, line 55

Code

function conflict_paragraphs_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_state
    ->get('conflict.build_conflict_resolution_form')) {
    $manual_merge_conflicts = $form_state
      ->get('manual-merge-conflicts');
    if ($manual_merge_conflicts) {

      /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
      $entity = $form_state
        ->getFormObject()
        ->getEntity();
      foreach ($manual_merge_conflicts as $field_name => $conflict_data) {
        if (ParagraphsWidget::isApplicable($entity
          ->getFieldDefinition($field_name)) && isset($form[$field_name]['conflict_resolution'])) {
          unset($form[$field_name]['conflict_resolution']);
        }
      }
    }
  }
}