-
-
Save webflo/0c855cb0e234d7d60672 to your computer and use it in GitHub Desktop.
Create link with attributes in Drupal 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = Url::fromRoute('node.add', array('node_type' => $content_type)); | |
$url->setOption('query', \Drupal::destination()->getAsArray(),); | |
$link = [ | |
'#type' => 'link', | |
'#title' => t('Add !content_type content', array('!content_type' => $content_type)), | |
'#url' => $url, | |
'#attributes' => [ | |
'class' => ['button', 'button-action', 'button--primary', 'button--small'], | |
] | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment