Recent articles

Add ajax multiple autocomplete to textarea

In this article we will show a solution to add an ajax call to populate multiple information in a Drupal 8 form textarea element.

In this example, the script will autocomplete users list in the form for a custom module called MyModule. The user will enter first 2 letters of a name or email.

1) create a library

In MyModule.libraries.yml add the necessary javascript reference that will be used to populate the users in the form:

MyModule_lib:
  version: VERSION
  js:
    js/autocomplete.js: {}
  dependencies:
    - core/jquery
    - core/jquery.ui.autocomplete

The autocomplete function as dependencies which are based on jQuery library.

 

2) JS script

The jQuery autocomplete.js file that we use is copied below. It is implemented as Drupal behaviors You need to add this file in MyModule/js/ folder.
 

JS script:

Send HTML mails with Drupal 8

At the time of this article in October 2015, the HTML swiftmailer module version for Drupal 8 was not released. Thus the below solution is not relevant anymore but may help for configuration or setup. We also have a new post about installation of swiftmailer

Here is a possible solution for sending HTML mails with Drupal 8 specifically when creating custom modules.

The solution below uses Swiftmailer library.

The main module compatible with Drupal 8 can be downloaded here.

This version needs some corrections if it is used with a recent Drupal 8 release. In this case, these are the lines changed:

Configuring Drupal with remote database

Configuring Drupal with a remote database is possible and in some cases recommended.

Our Drupal 8 EK management tools application is a particularly good case where this setup is very helpful. EK manages Drupal system configuration database and content database separately. In other words, the installed database from Drupal 8 and the database where all EK custom modules save their data are different.

This configuration brings few benefits: