Skip to content

Instantly share code, notes, and snippets.

Jody Hamilton jodyHamilton

Block or report user

Report or block jodyHamilton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jodyHamilton
jodyHamilton / NumberCommasWidget.php
Created Apr 20, 2017
Drupal 8 number field widget that uses commas to separate thousands
View NumberCommasWidget.php
<?php
namespace Drupal\YourModule\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldFilteredMarkup;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\NumberWidget;
View paragraphs-not-orderable.patch
diff --git a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
index 48d6d2c48..f72b86d8a 100644
--- a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -879,7 +879,7 @@ public function formMultipleElements(FieldItemListInterface $items, array &$form
if ($this->realItemCount > 0) {
$elements += array(
- '#theme' => 'field_multiple_value_form',
+ '#theme' => $this->fieldDefinition->isOrderable() ? 'field_multiple_value_form' : 'field_multiple_value_without_order_form',
@jodyHamilton
jodyHamilton / ViewerJsFormatter.php
Created Jan 4, 2019
Drupal 8 viewer.js file formatter for embedded pdf previews
View ViewerJsFormatter.php
<?php
/**
* @file
* Contains Drupal\viewerjs\Plugin\Field\FieldFormatter\ViewerJsFormatter.
*
* Download the ViewerJS library
* at https://github.com/abuhamza/Viewer.js/archive/master.zip
* and extract it to libraries/viewerjs
* (so that the viewer.js will be located at
@jodyHamilton
jodyHamilton / twig changes
Created Sep 11, 2018
aria describedby errors
View twig changes
diff --git a/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig b/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig
index 9e6cc85d6..18523d252 100644
--- a/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig
+++ b/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig
@@ -79,6 +79,7 @@
{{ description.content }}
</div>
{% endif %}
+ {{ kint(children) }}
{{ children }}
View gist:525a873f7cb0d1669a1b158670da1eaf
diff --git a/src/FieldCollectionItemAccessControlHandler.php b/src/FieldCollectionItemAccessControlHandler.php
index 4c79e3d..41339d8 100644
--- a/src/FieldCollectionItemAccessControlHandler.php
+++ b/src/FieldCollectionItemAccessControlHandler.php
@@ -23,9 +23,13 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
}
// Here we will be if host entity was not set and entity is not new.
elseif (!$entity->isNew()) {
+ // Applications that were migrated throw errors on first save though
+ // the ui. This is a temporary work around for that.
View ga.patch
diff --git a/js/google_analytics.js b/js/google_analytics.js
index 0490c2b..dea81ae 100644
--- a/js/google_analytics.js
+++ b/js/google_analytics.js
@@ -15,7 +15,7 @@
// Attach mousedown, keyup, touchstart events to document only and catch
// clicks on all elements.
- $(document.body).on('mousedown keyup touchstart', function (event) {
+ $(document.body).on('mousedown keyup', function (event) {
View favorite.js
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import 'whatwg-fetch'; // https://www.npmjs.com/package/whatwg-fetch
class Favorite extends Component {
constructor() {
super();
this.toggleFavorite = this.toggleFavorite.bind(this);
this.saveFavorite = this.saveFavorite.bind(this);
View favorite.module
<?php
/**
* Implements template_preprocess_node().
*/
function favorite_preprocess_node(&$variables) {
$node = $variables['node'];
if ($variables['view_mode'] == 'full') {
$variables['#attached']['library'][] = 'favorite/favorite';
$variables['content']['favorite'] = array(
View allow_multiple_fields_no_tabledrag-8.2x.patch
diff --git a/docroot/core/config/schema/core.data_types.schema.yml b/docroot/core/config/schema/core.data_types.schema.yml
index 73db361..c6e4f8c 100644
--- a/docroot/core/config/schema/core.data_types.schema.yml
+++ b/docroot/core/config/schema/core.data_types.schema.yml
@@ -392,6 +392,9 @@ field_config_base:
required:
type: boolean
label: 'Required field'
+ orderable:
+ type: boolean
You can’t perform that action at this time.