Latest Drupal related questions

Score: 0
theme_preprocess_form_element can't remove $field_suffix
cn flag

I'm trying to remove #field_prefix by using theme_preprocess_form_element like this

function estore_preprocess_form_element(&$variables) {
  if (isset($variables['name']) && $variables['name'] == "field_dimensions[0][length]") {
    $variables['element']['#field_suffix'] = "";
  }
}

I can see in the debugger that code is working and setting the variable to empty, but once the page renders  ...

Score: 0
stckvrw avatar
How to get all the pages where a block is placed
gb flag

If I have a block as an entity inside of the function hook_entity_update(), then how to get the paths of all the pages where the block is placed? Can't find an anwser via Google.

Or maybe first I should get the regions? If so, how to get the regions and then the pages?

I see that I have the following four properties inside of the hook_entity_update() when the entity type is block: provider, visibilit ...

Score: 1
Missing module error while running unit test
ae flag

I am trying to run a unit test for one of my contributed modules in my local development environment. But it keeps throwing an error:

$:/path/to/web$ sudo -u www-data -E phpunit -c core/phpunit.xml profiles/abc/modules/contrib/entity_clone/tests/src/Functional/EntityCloneContentTest.php
PHPUnit 6.5.9 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\entity_clone\Functional\EntityCloneCo ...
Score: 0
David Lemon avatar
Using radio FormElement in a drupal 8 ListBuilder
ke flag

I made a custom configuration entity, and I'm trying to set up radio buttons in the listBuilder. This is done in the core module language without any problems, but when I try to do the same trick with my custom entity I can't get any radio button. Instead the attributes are rendered in the html element.

    public function buildRow(EntityInterface $entity) {
      $row['label'] = $entity->label();
  ...
Score: -3
Graple avatar
How do I export a list of users into an excel spreadsheet in Drupal 9
us flag

I'm using a Drupal 9 website and would like to export a list of the users into an excel spreadsheet. Would using the Views data export module be the best way to achieve this?

Score: 2
Why Can't I Upgrade from 9.2.3 to 9.2.4 Using Composer?
br flag

If I check for outdated artifacts using:

composer outdated "drupal/*"

I can see Core needs updating:

drupal/core                       9.2.3             9.2.4
drupal/core-composer-scaffold     9.2.3             9.2.4
drupal/core-dev                   9.1.5             9.2.4
drupal/core-recommended           9.2.3             9.2.4

...

However, when I try to update:

composer update drupal/core-reco ...
Score: 0
wildfeed avatar
How to modify a rendered HTML string by adding custom code to setContent() in core in a module?
jp flag

I want to override the HTML string returned by core using a custom module that replaces $content['#markup'], or the entire $content array returned by HtmlResponse::setContent().

I can override Response::setContent() by calling HtmlResponse::setContent(). Exactly how do I add this to a custom module, for example implementing a service?

My goal is altering all the <a> tags to add a <span&g ...

Score: 2
Chris Happy avatar
Custom Submit Callback only triggering when Form is Valid when in Dialog
cg flag

I'm trying to create a node in a dialog with the following link:

Enter the title of a registration form or <a class="use-ajax" 
    data-dialog-options="{&quot;width&quot;:800}" 
    data-dialog-type="modal" 
    href="/node/add/mycontenttype?enableAjaxSubmit=true">
    create a new registration form.
</a>

The callback _mymodule_close_dialog() runs perfectly when there are no va ...

Score: 1
Inbound path processor is not processing
cn flag

I'm trying to use an Inbound Path Processor to redirect a path(to a webapp based on this tutorial), but Drupal is not picking it up.

I tried the following code to simply redirect every page on the site to /happy, but after rebuilding the cache, nothing happens; I can navigate the site normally and never get redirected.

/mymodule/src/PathProcessor/MyPathProcessor.php

namespace Drupal\mymodule\PathProce ...
Score: 0
Create a view filter to find node which have no value in a specific field
ru flag

I'm trying to create an exposed filter for view which allow to find node which have a specific field with no value. It's a field which lists taxonomy terms.

This is not possible with view. When I select to exposed the operator "IS NULL", the filter which is return by view make no sense as you can see on the following images

enter image description here

The filter after I choose this option:

enter image description here

In another issue on stackexchange, s ...

Score: -1
How can I remove some measure units from the Physical Fields widget?
cn flag

I'm trying to alter the widget for the fields implemented by the Physical Fields module, using hook_field_widget_form_alter().

I'm trying to remove some units from the select list, but there isn't a select list in $element.

How can I alter those units?

Score: 1
Berry Dingle avatar
Do I need to set up public files directory for multi-sites differently?
cn flag

I had some Drupal installations which I merged into a multi-site installation.

When they were single installations, I created a files in the root directory and set the system permissions for the directory and its content to 755. When I ran the security review, I got no errors.

Now I set up them as multi-site; the files directory is still in the root folder, and inside there also the site1, site2, si ...

Score: 0
Protomancer avatar
How do I properly render links in custom item list when using complex render array?
ar flag

I wish to use a custom item list template in a module that changes the <h3> tag. The items I am rendering are link render arrays.

When I use the default template, a link render array works correctly and outputs the links. When I use a custom template, the links no longer appear. Am I missing a step?

This is the code I am using in the module.

function mymodule_theme($existing, $type, $theme, $path ...
Score: 0
youni avatar
Show a block only in in the front page and not in every pager page
cn flag

I configured a block to be shown only on the front page, but the front page is actually a view of the last published nodes, with a pager, and the block is shown on each of its pages.

Is there any convenient way to show the block only once? I know it is possible to write a hook that checks if the page parameter is set and hide the block in that case.

What hook should I use to achieve this?

Score: 0
matts213 avatar
Add class to field parent with a preprocess hook in a custom module?
cn flag

Background:

I would like to alter the classes that are added to a rendered field in Drupal 9 in a custom module. I'm trying to use hook_preprocess_field and I'm not sure if this will work or if there is a better alternative.

based on: https://www.drupal.org/forum/support/module-development-and-code-questions/2017-03-31/add-class-to-field-in-drupal-8

I have the following:

function my_module_preproc ...

The Stunning Power of Questions

Much of an executive’s workday is spent asking others for information—requesting status updates from a team leader, for example, or questioning a counterpart in a tense negotiation. Yet unlike professionals such as litigators, journalists, and doctors, who are taught how to ask questions as an essential part of their training, few executives think of questioning as a skill that can be honed—or consider how their own answers to questions could make conversations more productive.

That’s a missed opportunity. Questioning is a uniquely powerful tool for unlocking value in organizations: It spurs learning and the exchange of ideas, it fuels innovation and performance improvement, it builds rapport and trust among team members. And it can mitigate business risk by uncovering unforeseen pitfalls and hazards.

For some people, questioning comes easily. Their natural inquisitiveness, emotional intelligence, and ability to read people put the ideal question on the tip of their tongue. But most of us don’t ask enough questions, nor do we pose our inquiries in an optimal way.

The good news is that by asking questions, we naturally improve our emotional intelligence, which in turn makes us better questioners—a virtuous cycle. In this article, we draw on insights from behavioral science research to explore how the way we frame questions and choose to answer our counterparts can influence the outcome of conversations. We offer guidance for choosing the best type, tone, sequence, and framing of questions and for deciding what and how much information to share to reap the most benefit from our interactions, not just for ourselves but for our organizations.