You are here

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

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

File

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

Class

EntityReferenceBrowserTableWidget
Plugin implementation of the 'entity_reference_browser_table_widget' widget.

Namespace

Drupal\entity_browser_table\Plugin\Field\FieldWidget

Code

public function buildEditButton(EntityInterface $entity, $details_id, $row_id, $field_parents) {
  return [
    '#type' => 'submit',
    '#value' => $this
      ->t('Edit'),
    '#name' => $this->fieldDefinition
      ->getName() . '_edit_button_' . $entity
      ->id() . '_' . $row_id . '_' . md5(json_encode($field_parents)),
    '#ajax' => [
      'url' => Url::fromRoute('entity_browser.edit_form', [
        'entity_type' => $entity
          ->getEntityTypeId(),
        'entity' => $entity
          ->id(),
      ]),
      'options' => [
        'query' => [
          'details_id' => $details_id,
        ],
      ],
    ],
    '#attributes' => [
      'class' => [
        'edit-button',
      ],
    ],
    '#access' => $this
      ->getEditButtonAccess($entity),
  ];
}