Latest Drupal related questions

Score: 1
CKL avatar
How do I set the default value for a user entity reference field in hook_form_alter()?
us flag
CKL

I tried the following code, but it doesn't work.

$form['field_name']['widget'][0]['target_id']['#default_value'] = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
Score: 1
Tobias Krause avatar
entityQuery returns wrong result: too many joins?
cn flag

I built an entityQuery for a custom entity type "vote". I only want to get those votes for a specific poll and those by deputies who are members of a specific fraction. The fraction membership can change over the time of the legislature so we have an additional custom entity of type "fraction_membership" in which the fraction and the time during which the fraction membership was valid can be set. So wha ...

Score: 0
Jaypan avatar
Creating a view with an exposed filter for "is not empty" where all results are shown by default
de flag

I'm creating a view. By default, I want all results shown, with an exposed filter for 'has a value' (aka is not empty) and 'is empty'.

I cannot figure out how to make the exposed filter work for this. If I make the exposed filter on either 'is empty' or 'is not empty', it filters the values initially based on that section. I only want the exposed filter to take effect when the value is in the URL ...

Score: 1
Søren Sjøstrøm avatar
Site branding not displaying correctly
ru flag

I'm working on a new theme for the Rain distribution (Drupal 9), but I'm having a hard time showing site branding correctly. This is the first time I'm trying to make a theme, so sorry if I ask stupid.

Site_logo, site_name and site_slogan are displayed on top of each other.

Here are excerpts from cloud_theme.theme:

/**
 * Implements hook_preprocess_HOOK().
 */
function cloud_theme_preprocess_block(array  ...
Score: 1
How to create a view printing the latest 3 nodes with unique entity reference values
nl flag

I have two content types, CAR and DRIVER. The DRIVER content type contains a CAR entity reference field. So each DRIVER node creation page can reference a specific CAR.

The goal is to build a view to print out 3 of the most recent unique CARs referenced from a DRIVER node (created by the logged-in user).

Example... here are 6 of the most recently created DRIVERS by a particular user.

  • Driver 1 - B ...
Score: 0
ProGrammar avatar
Paragraphs removed from graphql schema if not anywhere in content, which causes error for union type
ca flag

I'm making a headless Drupal site with Gatsby using paragraphs. I'm experienced with Drupal but relatively new with gatsby/graphql.

The issue I'm running into is that if our database does not actually have any instances of a paragraph, then it generates the schema without that (i guess it generates a minimal schema based on what exists, not what types are actually possible) and it errors out beca ...

Score: 0
Rishi Kulshreshtha avatar
Mocking the response of XmlResponse::getResultCode not working
uz flag

Following is the code that I'm using to mock the response of XmlResponse::getResultCode as Ok, but it isn't working, I'm not sure what exactly is going wrong here:

$response = $this->createPartialMock('\CommerceGuys\AuthNet\Response\XmlResponse', ['getResultCode']);
$response->expects($this->any())->method('getResultCode')->will($this->returnValue('Ok'));

$client = $this->createMock ...
Score: 0
Is there an easy way to get the image derivatives links?
by flag

I'm working with complex image styles, and I'd like to be able to load all the different derivatives quickly to check they're being processed correctly.

But I don't see how to easily get the links. The best I can come up with is opening the node in JSONAPI and, with the patch from https://www.drupal.org/project/drupal/issues/2825812, getting the URLs for derivatives from that.

It there something easi ...

Score: 0
Paul avatar
Optimal way to get a content type's field definition
in flag

When I need a content type's field definition in Drupal 8+, I used to run the following code (for getting 'body' field in content type 'page'):

$page_fields = \Drupal::getContainer()->get('entity_field.manager')
               ->getFieldDefinitions('node', 'page'); 
$body_definition = $page_fields['body'];

I learned, that it is also possible by running the following code:

$body_definition = ...
Score: 0
ANDREW-LVIV avatar
How do I grant to a role the permission to flush the cache?
us flag

I removed the Administer site configuration permission from a role, but I need users with that role to flush the cache from /admin/config/development/performance.

I know, there is hook_menu_alter() in Drupal 7, but what about Drupal 8?

Score: 0
Show currently active multisite
cn flag

Is there a way to see which multisite configuration is currently active in the drupal admin web interface?

Score: 0
user3108268 avatar
Validation doesn't show an error when the value entered in the field doesn't respect the minimum length
us flag

I am using the Field validation module to validate a text field using the Length rule with a minimum length of 1.

screenshot

When the field is left empty, no validation error is shown.

screenshot

Setting the field as required is not the solution for this specific case, as it causes problems with a module I am using.

How can I avoid users don't enter a value for that field?

Score: 0
Tobias Krause avatar
Chained tokens for referenced custom entities
cn flag

We have two custom entities: parliament_period (can be an election or a legislature) and parliament. A parliament_period entity has a reference to a parliament entity. In a Poll node, we have an entity reference field for parliament_period entities whose bundle is legislature (field_legislature). (It is about polls the deputies take part of.) Part of the path alias for Poll nodes should be the content  ...

Score: 0
Mathieu avatar
How do I display a tour on a node?
ph flag

On a Drupal 9 site, I installed the Tour and the Tour UI modules, and created a node.

How can I configure the Tour UI to show a tour on that node?

I don't know what to put in Module name and Routes.

screenshot

Score: 1
How can I make 3 different menus?
cn flag

I need to do an Agenda in Drupal 7. The table for the events is more or less already done, but I would need to add 3 days on the top like:

Day 1 - Day 2 - Day 3

Depending on which day is clicked, it will show an agenda or the other.

How can I do this?

I'm adding the content using the Agenda content type I created, but I would need to create content for those 3 days.

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.