Skip to content

Instantly share code, notes, and snippets.

View gauravgoyal's full-sized avatar

Gaurav Goyal gauravgoyal

View GitHub Profile
@gauravgoyal
gauravgoyal / createMenuLink.php
Last active January 18, 2022 11:05
Create menu programmatically in Drupal 9
brew unlink php && brew link --overwrite --force php@7.4
@gauravgoyal
gauravgoyal / enableBlockMenu.js
Created April 16, 2020 09:21
Enable menu_blocks on layout
jQuery('#edit-layout-builder-restrictions-allowed-blocks--13 input').each(function(e) {
var name = jQuery(this)[0].name;
if (name.indexOf('[menu_block:') != -1) {
jQuery('input[name="' + name + '"]').prop( "checked", false);
}
})
@gauravgoyal
gauravgoyal / Lotus.php
Created April 11, 2017 17:40
Task-17: Define a custom config entity
<?php
namespace Drupal\lotus\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\lotus\LotusInterface;
/**
* Defines the lotus entity.
*
@gauravgoyal
gauravgoyal / SimpleForm.php
Last active May 9, 2020 14:04
Task-12: Build a new Form
<?php
namespace Drupal\lotus\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements a simple form.
*/
@gauravgoyal
gauravgoyal / example.module
Last active April 11, 2018 08:49
Task-11: Alter an existing simple form
<?php
/**
* @file
* Change the label of Comment form button to 'Add Comment'
*/
use Drupal\Core\Form\FormStateInterface;
/**