- August 24, 2016 - 18:44
- July 21, 2016 - 06:24
I had a requirement to handle multiple buttons in a custom form in Drupal 8. In Drupal 7 we can add multiple submissions using the button definition ['#submit'] => array('my_submit_function'). In drupal 8, same process is possible with slight changes as, ['#submit'] => array('::newSubmissionHandler') in button definition. Also we can get the form values to the custom submit handler as same as default handler. Just see the sample code below for more explanation. Note that the form should be saved in src/Form/MyForm.php.
- July 15, 2016 - 11:21
Coder is a Drupal module to check for coding standard issues in custom modules and themes. It can check any files for coding standard issues according to Drupal specifications. This method uses latest composer and drush to install latest coder. Feel free to skip the following to corresponding parts you need.
Check if composer is installed,
If this is empty, proceed with below command. Else skip.
- May 09, 2016 - 07:48
- May 09, 2016 - 07:45
- May 09, 2016 - 07:42
In Drupal 8, third party libraries are downloaded and managed via composer. In each Drupal project there must be only one vendor folder. Composer Manager allows a single vendor/directory shared across all modules which prevent code duplication and version mismatches. This is done by merging the requirements of all modules found, into the consolidated composer.json file. In a custom module, set the dependency for composer manager module in .info file.
- May 09, 2016 - 07:40
I had a requirement to import bulk data to database. Drupal module feeds helps you with this.
Either you can add url of the data to be imported or upload the file which has bulk data. If want to add url to import data from some other source, use feed importer. The steps to create a feed importer are here.
If you want to import as a file, use the following steps:
- May 09, 2016 - 07:31
In Drupal 7, the function drupal_get_path_alias is used to get the path alias from internal path and arg function is used to get arguments from url. But both these functions are deprecated in Drupal 8.
Drupal 8 uses service container to access various services such as sending an email, accessing a database etc. This ensures that a decoupled nature of the system is respected. We will use the services of current path and path alias to get the result.