Latest Drupal related questions

Score: 0
Nikodem Miranowicz avatar
User with only "Edit own webform" permission cannot add elements to own webform
ph flag

I have created a "form admin" role with three permissions only: "Access the webform overview page", "Create webforms", "Edit own webform" (Drupal 9.3.7, Webform 6.1.3). The user can create a webform but when trying to add an element then the page goes into "reload loop" (see two screenshots). The issue disappears only if I add "Administer webforms" permission or enable "access webform configuration" for ...

Score: 0
Asatur Vardanyan avatar
Migrate paragraph field
jp flag

I have events on my Drupal 7 websites and after the upgrade, I want to migrate those events to the Drupal 9 website. Event CT has a paragraph reference revision field to the 'event_date' paragraph on the Drupal 9 website. Inside the paragraph, there are fields like field_city, field_country, and others. On the Drupal 7 site, this paragraph has a location field referenced to the location entity. Now I wa ...

Score: 0
simp you avatar
how to get file id
ph flag

I have this webform submission hook and i want to add a file to it when its submitted. I know how to alter the webform submission but now i have an issue that i want to load a file but i don't know the id, only it's url:

Url: /sites/default/files/assets/filename.pdf

i have tried:

   $file_name = Drupal::service('file_system')->basename($filename);

   //$file_name gives me the correct name


  $tar ...
Score: 1
kniro avatar
TypeError: Argument 1 passed to ........ ::__construct() must implement interface Drupal\Core\Cache\CacheBackendInterface, array given, called in
pe flag

I'm getting an error when I wrote the code using Dependency injection:

TypeError: Argument 1 passed to Drupal\sydneypro_exchange_rates_block\Plugin\Block\ExchangeRatesBlock::__construct() must implement interface Drupal\Core\Cache\CacheBackendInterface, array given, called in /var/www/web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php on line 25 in Drupal\sydneypro_exchange_rates_block\Plugin\ ...

Score: 0
Morgan P avatar
How can I get an image URL in a view field?
us flag

I followed what suggested in How can I get the image URL in a field?

It worked well until I migrate to Drupal 9. It now displays /system/files/provider/products-variations/1/collier-saskia-bleu-nuit.jpg instead of https://example.com/system/files?file=provider/products-variations/1/collier-saskia-bleu-nuit.jpg.

I also tried with the URL to image formatter that is part of Drupal core, but I get th ...

Score: 0
Clear specific view's cache programmatically, specific to contextual filter
de flag

I am using the following to clear view specific cache on node_presave which is working fine.

  cache_clear_all($view_name.':'.$display_name, 'cache_views_data', TRUE);

Currently, it is deleting all the views generated for all Contextual Filters(taxonomy term id). I want to be able to delete only the view for one taxonomy term id.

For example, if the node a with tid:46 is added,

What is happening: All th ...

Score: 1
How does SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 work exactly?
ca flag

I ran into an issue (When using fpm, it is not clear how to make image styles work ) which I traced back to the use of Drupal_Security_Do_Not_Remove_See_SA_2006_006 in sites/default/files/.htaccess.

In order to continue debugging I would need a more solid understanding of what exactly "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006" does in that file, because when I comment it out, my issue is r ...

Score: 0
How do I get JS event attached to multiple views rows
pl flag

I am creating a custom views field and need it to have JS attached to it's on click functionality. When I get one views result, it works perfectly, but when I have multiple results, it only attaches to one of them. How do I get this to attach to all the result rows?

Below is the code for rendering the field and the js that gets attached. Any help is appreciated.

<?php

/**
 * @file
 * Contains \Dr ...
Score: 1
Extend core select widget
tr flag

Please help with the following:

I need a new widget (just a slightly altered select) that can be setup from the UI by anyone. I have done the following:

  1. Created a new custom module and enabled it.

  2. Created a new widget.

<?php

namespace Drupal\filtered_select\Plugin\Field\FieldWidget;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidg ...
Score: 0
ACanadianCoder avatar
Upgrading from 8.9.20 to 9.3.9 causing errors
br flag

As the title suggests, I'm running into composer issues that I can't seem to figure out. I've found a few similar articles but none of them have seemed to fix my instance.

I've been following the steps from Upgrading from Drupal 8 to Drupal 9 (or later) and got stuck on step 3 composer update. I get the following errors:

Your requirements could not be resolved to an installable set of packages.

  Prob ...
Score: 0
Joseph avatar
How can I make a custom module link appear on /admin/config?
cn flag

I have a custom module I'm working on and I'd like to make it configurable via the admin menu. I'm having difficulty getting a form to appear in the admin page.

Visting admin/config/MYMODULE does show the form, it's just not visible on the /admin/config page.

Here is my file structure so far (excluding irrelevant files):

*The form file is just an example form to try to get it to appear on the admin pag ...

Score: 0
Baud avatar
Why a form doesn't keep the value created during construction
sa flag

Here is a form using DI for $this->entity_type_manager

There is also a radio-button with Ajax (I have added the code as it is maybe the reason of my problem)

class myForm extends FormBase {

  private ?EntityTypeManagerInterface $entity_type_manager=NULL;

  public function __construct(Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager) {

    $this->entity_type_manager=$entit ...
Score: 0
How can I make this JavaScript code get executed when the BigPipe module is enabled?
bj flag

I keep struggling with getting JavaScript executed when I need to target a DOM element that is added via the BigPipe module when I'm logged in on my Drupal site.

The following code runs when I'm not logged in, but it's never executed when I am logged in.

(function ($) {
  'use strict';

  Drupal.behavior.bpBlockTest = {
    attach: function(context, settings) {
      $('.my-block', context).once('bp-bloc ...
Score: 0
If content not published, hide also for admin
kn flag

I have a entity browser which list my produts. The products are shown only if they are published.

enter image description here

But for some reason, if the product was added before the filtered "publish" was set, the product is still displayed but only for the admin.

How can I prevent the admin to see it ?

EDIT :

For now, I've added a manual check in twig, but i think there's a cleaner way to do it

{% for produit in produits %} ...

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.