You are here

public function EntityReferenceBrowserTableWidget::buildRemoveButton in Entity Browser - Table Layout 8

1 call to EntityReferenceBrowserTableWidget::buildRemoveButton()
EntityReferenceBrowserTableWidget::buildTableRows in src/Plugin/Field/FieldWidget/EntityReferenceBrowserTableWidget.php

File

src/Plugin/Field/FieldWidget/EntityReferenceBrowserTableWidget.php, line 276

Class

EntityReferenceBrowserTableWidget
Plugin implementation of the 'entity_reference_browser_table_widget' widget.

Namespace

Drupal\entity_browser_table\Plugin\Field\FieldWidget

Code

public function buildRemoveButton(EntityInterface $entity, $details_id, $row_id, array $field_parents) {
  return [
    '#type' => 'submit',
    '#value' => $this
      ->t('Remove'),
    '#ajax' => [
      'callback' => [
        get_class($this),
        'updateWidgetCallback',
      ],
      'wrapper' => $details_id,
    ],
    '#submit' => [
      [
        get_class($this),
        'removeItemSubmit',
      ],
    ],
    '#name' => $this->fieldDefinition
      ->getName() . '_remove_' . $entity
      ->id() . '_' . $row_id . '_' . md5(json_encode($field_parents)),
    '#limit_validation_errors' => [
      array_merge($field_parents, [
        $this->fieldDefinition
          ->getName(),
      ]),
    ],
    '#attributes' => [
      'data-entity-id' => $entity
        ->getEntityTypeId() . ':' . $entity
        ->id(),
      'data-row-id' => $row_id,
      'class' => [
        'remove-button',
      ],
    ],
    '#access' => (bool) $this
      ->getSetting('field_widget_remove'),
  ];
}