How can you contact us

2By phone at +40 749 014 360

If you still have problems, please let us know, by sending an email to Thank you!


Mon-Fri 9:00AM - 6:00AM
Sat - 9:00AM - 1:00PM
Sundays by appointment only!

Drupal 8 - How to add translation for menu items

In this article, you will learn how to add a translation for Drupal 8 Menus. You can do this in 5 steps.

1. Go at admin/config/regional/content-language and check Custom menu link

2. Clear cache

Drupal 8 Menu Translation

In Drupal 8 it is easy to attach a cs/js to a template file.

We need to define a library that will contain the js/css files needed.

The libraries are defined in the file mymodule.libraries.yml
There, we define the each library with their js, css and dependencies of other libraries.

Drupal 8 theme hook_theme

Drupal 8 - How to use hook_theme

In this tutorial I will show you a quick implementation of hook_theme, that will list the title/body of a FAQ nodes.

I've created a new routing and a new controller class (FaqController) for this.

  path: 'faq'
    _controller: '\Drupal\mymodule\Controller\FaqController::faq'
    _title: 'FAQ'
    _permission: 'access content'

Because I want to get all FAQ nodes, I'm injecting the entity_type.manager service into our controller class.

Drupal 8 theme hook_theme

Drupal 8 - How to create a simple config form

To create a configuration form, we need to extend our form from ConfigFormBase and not from FormBase like we do in case of a normal form.

Extending the ConfigFormBase, we need also to implement the getEditableConfigNames() method, that will return an array with condiguration names that are editable.

In the buildForm() method, we need to create all form elements that will be used to input the settings. For this, we can use the form API of Drupal 8.

Of course, we can have access to our configuration object and get all our configurations from it.

Drupal 8 form config form

Similar to Drupal 7, we are able to pass custom data between form validate/submit callbacks.

In Drupal 8, there are two way of setting a key => value to $form_state: set a single key => value or multiple keys => values.

To set a single key, we can use set() method that is defined in FormStateInterface interface.

Drupal 8 form form_state

In order to attach custom validate/submit callbacks to an existing form in Drupal 8, you need to alter it.

To alter an existing form, we need to use the hook_form_alter() function.

Let's suppose for example that we have an existing form called example_form defined in a module example.

An we have a module called mymodule, where we want to alter the example_form and add our custom validate/submit callbacks.

The first step is to implement the hook_form_alter() in your mymodule.module file.

Drupal 8 form form_validate form_submit

Drupal 8 - How to replace drupal_get_form()

In this tutorial I will show you how to create a simple form using Drupal 8.

In order to create a new form, we need to extend the FormBase class. The FormBase class is implementing the FormInterface interface, so our class needs to implement the methods from FormInterface.

The place where we create forms in Drupal 8 is: /mymodule/src/Form

The class name should end in 'Form', for example: ExampleForm.

The methods from FormInterface are:

Drupal 8 form drupal_get_form

Drupal 8 - How to subscribe to an event

In this 'How to' I will show you how to subscribe to an exisitng event.

You can read my previous article on How to dispatch an event.

1 Create a new file in root if your module

In this file, we need to create a new service and tag it as an 'event_subscriber' so Drupal will know that this service is an event subscriber.

Drupal 8 Event Dispatcher

Sign in your account to have access to different features

Forgot your details?