Skip to content
Snippets Groups Projects
Commit 61e760cb authored by Kostia Bohach's avatar Kostia Bohach
Browse files

Issue #3425102: Add link to the Manage fields for the node type on the node edit page

parent e935dba2
No related branches found
Tags 1.0.4
1 merge request!4Issue #3425102: Add link to the Manage fields for the node type on the node edit page
Pipeline #108813 passed with warnings
.field--widget-entity-reference-autocomplete:has(.reference-edit-link),
.field--widget-select2-entity-reference:has(.reference-edit-link) {
display: flex;
justify-content: space-between;
align-items: flex-start;
justify-content: space-between;
}
.field--widget-select2-entity-reference:has(.reference-edit-link) .form-type--select {
......@@ -29,7 +29,7 @@
}
.field--widget-entity-reference-autocomplete .reference-link .reference-edit-link {
height: auto;
margin-top: var(--space-s);
margin-bottom: var(--space-s);
height: auto;
}
......@@ -5,10 +5,13 @@
* This is the module to create a drop-down menu for the core toolbar.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\entity_reference_edit_link\Plugin\Field\FieldWidget\EntityReferenceEditLinkAutocompleteTagsWidget;
use Drupal\entity_reference_edit_link\Plugin\Field\FieldWidget\EntityReferenceEditLinkAutocompleteWidget;
use Drupal\node\NodeForm;
/**
* Implements hook_preprocess_HOOK().
......@@ -108,3 +111,29 @@ function entity_reference_edit_link_field_widget_complete_form_alter(&$field_wid
'_link' => $link,
];
}
/**
* Implements hook_form_alter().
*/
function entity_reference_edit_link_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$formObject = $form_state->getFormObject();
// Currently worked only for the nodes.
if (!$formObject instanceof NodeForm || $formObject->getOperation() != 'edit') {
return;
}
$node = $formObject->getEntity();
if (!$node) {
return;
}
$url = Url::fromRoute("entity.{$node->getEntityTypeId()}.field_ui_fields", [
'node_type' => $node->bundle(),
],
[
'attributes' => ['target' => '_blank'],
]);
$form['#title'] = t('<em>Edit @type</em> @title', [
'@type' => Link::fromTextAndUrl(node_get_type_label($node), $url)->toString(),
'@title' => $node->label(),
]);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment