drupal_get_form in Drupal 8
In Drupal 8 you use the FormBuilder service to retrieve forms.
1
|
|
The argument passed to the getForm() method is the name of the class that defines your form and is an implementation of \Drupal\Core\Form\FormBuilderInterface. If you need to pass any additional parameters to the form, pass them on after the class name.
1
|
|
module_exists in Drupal 8
How to check if a module is enabled in Drupal 8:
1
|
|
HTML link in Twig
In Drupal 7, you could use the array('html' => TRUE)
parameter to make an HTML link. Here’s how to do it in Twig.
1
|
|
Note that url should be an instance of \Drupal\Core\Url
.
menu_tree() in Drupal 8
1 2 3 |
|
How to dpm in Drupal 8
Looks like dpm()
is broken right now in devel. It gives you a WSOD.
Here’s some alternatives with the devel module enabled:
1. Krumo
1
|
|
2. Kint
Kint is a great alternative to Krumo.
1
|
|
2. Dump for Twig
Inside Twig template you can:
1
|
|
How to exclude or remove stylesheets added by core or other modules
In Drupal 8, you can easily remove stylesheets added by core, other modules or themes from your custom theme.
Simply add the following lines to your THEMENAME.info.yml file
1 2 3 |
|
Current logged in user in Drupal 8
1
|
|
How to check for user access or permission in Drupal 8
In Drupal 7, you would use the user_access function to check for user access. Here’s how to do it in Drupal 8.
1 2 3 4 5 |
|
How to set active links for menu items
In your THEMENAME.theme file, add the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
How to get the current path in Drupal 8
1
|
|