Skip to content

Instantly share code, notes, and snippets.

@woombo
woombo / hook_inline_entity_form_table_fields_alter.module
Last active February 11, 2016 18:12
hook_inline_entity_form_table_fields_alter()
/**
* Implements hook_inline_entity_form_table_fields_alter().
*/
function MODULE_inline_entity_form_table_fields_alter(&$fields, $context) {
if ($context['parent_bundle'] === 'MODULE' &&
$context['entity_type'] === 'MODULE_text_asset') {
// Remove Title.
unset($fields['id']);
<?php
/**
* @Then /^I fill in wysiwyg on field "([^"]*)" with "([^"]*)"$/
*/
public function iFillInWysiwygOnFieldWith($arg, $arg2)
{
$this->getSession()->executeScript("CKEDITOR.instances.$arg.setData(\"$arg2\");");
}
@AkshayKalose
AkshayKalose / ajax_example.info.yml
Last active November 23, 2022 13:40
Drupal 8 - Ajax Example
name: 'Ajax Example'
description: 'Just an Ajax Example'
core: 8.x
type: module
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 01:27
Test Height
/**
* See if the element (name|label|id) is greater than the % of the window
*
* @Then /^the element "([^"]*)" should be "([^"]*)" percent or greater than the window$/
*/
public function theElementShouldBePercentOrGreaterThanTheWindow($arg1, $arg2)
{
//@todo
$javascript_check = <<<HEREDOC
if(!jQuery('$arg1').length) { return "FAILED"; }
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 01:20
Switch to popup
/**
* @hidden
*
* @Then /^I switch to popup by clicking "([^"]*)"$/
*/
public function iSwitchToPopupByClicking($arg1) {
$originalWindowName = $this->getMainContext()->getSession()->getWindowName();
$this->setMainWindow();
$this->getMainContext()->getSession()->getPage()->clickLink("$arg1"); //Pressing the withdraw button
@alnutile
alnutile / alert.php
Last active July 1, 2016 21:01
Dealing with Alerts
/**
* @hidden
*
* @Then /^I click on the alert window$/
*/
public function iClickOnTheAlertWindow() {
$this->getMainContext()->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 01:02
Allow user to submit a form with no submit button
/**
* Some forms do not have a Submit button just pass the ID
*
* @Given /^I submit the form with id "([^"]*)"$/
*/
public function iSubmitTheFormWithId($arg)
{
$node = $this->getMainContext()->getSession()->getPage()->find('css', $arg);
if($node) {
$this->getMainContext()->getSession()->executeScript("jQuery('$arg').submit();");
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 00:57
No name iframe
/**
* Sets an iFrame ID to no_name_iframe if there is no ID. You can then add a Switch to iFrame step after it using the na_name_iframe ID.
*
* @Given /^I the set the iframe located in element with an id of "([^"]*)"$/
*/
public function iSetTheIframeLocatedInElementWithAnIdOf($element_id) {
$check = 1; //@todo need to check using js if exists
if($check <= 0) {
@dr-dimitru
dr-dimitru / Social RESTful URLs snippet.md
Last active January 28, 2023 03:57
Social links, +1s and shares using only HTML (no JS)
@juampynr
juampynr / mymodule.info
Last active June 9, 2023 21:53
Drupal 7 Views 3 custom field handler
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_handlername.inc