Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

2

Following example unsets the filter average when user is NOT administrator, you can modify it to your specific case. use Drupal\Core\Form\FormStateInterface; function my_modulename_form_alter(&$form, FormStateInterface $form_state, $form_id){ $roles = \Drupal::currentUser()->getRoles(); $is_user_admin = in_array("administrator", $roles); $...


1

I would like to know if there is a way to target only that node type directly from the hook and not to have the hook triggered for all nodes and then checking the node type. Node hooks aren't that granular, they're invoked for all nodes and there isn't a system in place to make that selective based on the type. If you're worried about performance, don't be; ...


1

I gave up on hook_views_pre_render and wound up meeting my requirements with template_preprocess_image_formatter as follows: function <TEMPLATE_NAME>_preprocess_image_formatter(&$variables) { $styles = array('thumbnail', 'medium', 'large'); if ($variables['image']['#style_name'] === 'medium') { $variables['image']['#style_name'] = $styles[...


1

Extending the WebformMessageManager is the right approach to address the immediate issue/limitation of hardcoded messages. To address the specific issue of changing the hardcoded WebformMessageManagerInterface::DRAFTS_PREVIOUS message in /webform/src/WebformMessageManager.php, I created Issue #3050884: Allow WebformMessageManagerInterface::DRAFTS_PREVIOUS ...


1

The beauty about Services is that they can be overridden to your liking. So all we have to do is extend the WebformMessageManager so we inherit all of it's properties and methods and simply alter the method you need to modify. my_module/src/CustomWebformMessageManager.php <?php namespace Drupal\my_module; use Drupal\webform\WebformMessageManager; use ...


1

As seen in webform_example_handler You need to add: mymodule/mymodule.module <?php /** * @file * Provides a custom webform handler. */ /** * Implements hook_theme(). */ function mymodule_theme() { return [ 'webform_handler_myform_form_handler_summary' => [ 'variables' => ['settings' => NULL, 'handler' => []], ], ]; }...


Only top voted, non community-wiki answers of a minimum length are eligible