Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Commit

Permalink
Issue #2513086 by JamesK: Right click option to edit entity: not refe…
Browse files Browse the repository at this point in the history
…rence a different entity, but *edit* the entity in a dialog
  • Loading branch information
yannickoo committed Jun 13, 2016
1 parent 607254d commit b3f2e89
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Form/EntityEmbedDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,40 @@ public function buildEmbedStep(array $form, FormStateInterface $form_state) {
'#title' => $this->t('Selected entity'),
'#markup' => $entity_label,
);

$edit_url = $entity->urlInfo('edit-form');
$form['entity_edit'] = [
'#type' => 'link',
'#title' => $this->t('Edit'),
'#url' => $edit_url,
'#attributes' => [
'target' => '_blank',
'class' => ['button'],
],
];

if ($this->moduleHandler()->moduleExists('entity_browser')) {
// Configuration entities have no form object so we provide a fallback
// to a normal link styled like a button.
try {
$edit_form = $this->entityManager()->getFormObject($entity->getEntityTypeId(), 'edit');

$form['entity_edit'] = [
'#type' => 'button',
'#executes_submit_callback' => FALSE,
'#value' => $this->t('Edit'),
'#ajax' => [
'url' => \Drupal\Core\Url::fromRoute(
'entity_browser.edit_form', [
'entity_type' => $entity->getEntityTypeId(),
'entity' => $entity->id(),
]
)
],
];
} catch (\Exception $e) {}
}

$form['attributes']['data-entity-type'] = array(
'#type' => 'hidden',
'#value' => $entity_element['data-entity-type'],
Expand Down

0 comments on commit b3f2e89

Please sign in to comment.