Skip to content

Instantly share code, notes, and snippets.

@cube-dan
cube-dan / AjaxForm.php
Created February 7, 2022 18:10 — forked from lcube45/AjaxForm.php
Drupal 8 - ajax callback & alter form
<?php
class SimpleForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'simple_form';
}
@cube-dan
cube-dan / yourmodule.tokens.inc
Created September 9, 2021 19:57 — forked from stevesmename/yourmodule.tokens.inc
[file:description] token working with 'Download link' format
<?php
/**
* @file
* Token integration for the file_entity module.
*/
/**
* Implements hook_token_info().
*/
@cube-dan
cube-dan / Blocks.md
Created December 9, 2020 19:20 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');