Skip to content

Instantly share code, notes, and snippets.

@pfaocle
pfaocle / gen-d8-salt.sh
Created March 8, 2016 09:39
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@jleehr
jleehr / domcheck.js
Last active August 15, 2024 20:05
Detection if an element is added to DOM
// Detection if an element is added to DOM
function onElementInserted(containerSelector, elementSelector, callback) {
var onMutationsObserved = function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
var elements = $(mutation.addedNodes).find(elementSelector);
for (var i = 0, len = elements.length; i < len; i++) {
callback(elements[i]);
}
}
@jez500
jez500 / TestAjaxFormSelect.php
Created January 8, 2018 00:53
Drupal 8 Ajax form example when select box changed
<?php
namespace Drupal\my_module\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class TestAjaxFormSelect.
*/
@chriscalip
chriscalip / cduxx_get_bulk_field_values.php
Created August 16, 2019 03:20
bulk data retrieval for drupal 8.
<?php
/**
* Utility get all field values
* @param string $entity_type Entity Type eg. (node,taxonomy)
* @param string $bundle Bundle (asset)
* @param string $field_name Field Name machine_name (field_asset_address)
* @param string $column_key $records keyed by column eg. (entity_id)
* @param array $columns Field columns eg. (value,uri,address_line1,locality)