Latest Drupal related questions

Score: 0
Webform sometimes not sent on pages using different theme (via theme negotiator)
cn flag

I have a website with a main theme and another "mini" theme that is used via a custom module with a theme negotiator, determined by node type. The pages using the mini theme include a webform, in a block.

The mini theme pages seem to display properly, including the webform, but in many cases after filling the form, the submission is not sent (not logged in tables and no confirmation). There are s ...

Score: 0
Kevin avatar
Deleting a Paragraph Item results in AJAX POST error "Missing bundle property on entity of type node."
in flag

Working with an older D7 site. On it, we have added the latest version of Paragraphs to add some content items to a page. This all works fine.

However, when trying to remove a Paragraph Item from the form, you get an AJAX error. The root of it is:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 8006 of /mnt/www/html/moswebsandbox1/docroot/include ...
Score: 0
Ivan Ginovski avatar
Toggle view displays on the same page
jp flag

There are 2 view displays (2 blocks) which are showing products, one with tile display, one with list display, as shown in the image below.

enter image description here

Is there a way to have both blocks on the same page, but toggle them with a button? Once the button is clicked, one block is hidden and the other one is shown. enter image description here

What would be the best way to achieve this? Is there a module that provides functionality about this?

Score: 0
FrankDesign avatar
Drupal 9 Commerce change the Pay button text
cn flag

I have created Drupal 9 website. On the website we accept donations using Commerce with Commerce Stripe as the payment processor. By default, the payment button says "Pay and complete purchase". As users are not purchasing anything, I want to change the text to something like "Donate Now". I have searched for answers online but all seem to point to the module String Overrides, which is D7 only and doesn ...

Score: 0
Jorn Reed avatar
Validation for radio inputs don't work for me
il flag

I'm building a form with the drupal forms api. Validation works well for all my other fields. But I've started to try and work with radio buttons too now. It doesn't matter if I click on a radio option, the validation returns always 'color is required'.

// Form build method code
$form['birthdate'] = [
  '#type' => 'date',
  '#title' => $this->t('Your date of birth'),
  '#date_date_format'  ...
Score: -1
Jorn Reed avatar
Formatting date field with the Form API
il flag

Hi there I'm using drupal 9.x and the forms api to generate a dynamic form. Altough I'm living in the Netherlands where the date format standard is 'dd/mm/yyyy'. I've looked around on the internet for recent ways to modify that format in the html input. But all ways seems to be deprecated cause they don't seem to work for me. I've tried stuff like:

$form['birthdate'] = [
  '#type' => 'date',
  ' ...
Score: 2
richirm avatar
drush cr on replicated servers
in flag

I am the administrator of a Drupal site replicated on 4 servers, behind a load balancer. There is only one database that is shared by the 4 instances. When I run drush cr, is it necessary to run it on each of the 4 nodes, or is it enough to run it on only one?

Score: 0
config:import:single - Class 'Drupal\config\StorageReplaceDataWrapper' not found
cn flag

When I am trying to import a single configuration file within my multisite environment, I am facing the following error:

root@d655a4e6dc36:/opt/drupal/docroot# drupal --uri="" config:import:single --directory="/opt/drupal/config/sync/" --file="core.extensions.yml"

Error: Class 'Drupal\config\StorageReplaceDataWrapper' not found in /opt/drupal/vendor/dru ...
Score: 0
getCommentedEntity returns null
in flag

I have a comments page set up and when I devel the page for a specific comment I see the getcommentedentity method. enter image description here

I am trying to get the commented entity details using the below code in my VBO action file:

public function execute(ContentEntityInterface $entity = NULL) {
    $comment = $entity->get('comment_body')->getValue();
    $commentid = $entity->get('cid')->getValue();
    $va ...
Score: 0
Update body field from ajax callback
cn flag

I need to update the common "body" field when I change some paragraph fields value.

Here is my hook_form_alter :

$form["body"]["#prefix"] = "<div id='body__update_real_time_seo'>";
$form["body"]["#suffix"] = "</div>";

$form["field_content_edito"]["widget"][3]["subform"]["field_paragraph_subtitle"]["widget"][0]["value"]["#ajax"] = [
    "callback"  => "_update_real_time_seo",
    "event"  ...
Score: 1
Fadi Alkhatib avatar
Adding Current Product page Variant ID/SKU to webform submission Drupal 8
it flag

I have product type event, this event have registration fees if price value not zero.

Product page built with views and I embed related webform inside it.

am using module called commerce webform order: which add handler to webform to create order and redirect user after submit webform to checkout page.

Currently I use fixed selected variant as screenshot below

enter image description here

This field needs to be filed with product I ...

Score: 2
Gabriel Fernandez avatar
hook_node_presave get original of translated node
cn flag

I'm using a hook_node_presave and I want to detect which field is updated when the translated node is updated. Here is my code :

function hook_import_node_presave(\Drupal\node\NodeInterface $node) {
  if (!$node->isNew()){
    $entityFieldManager = \Drupal::service('entity_field.manager');
    $fields = $entityFieldManager->getFieldDefinitions('node', 'article');
    foreach($fields as $field ...
Score: 1
thornley avatar
Difference between a front-end theme and an administrative theme?
im flag

I am teaching myself Drupal 9 and I see that the Claro theme is defined as a "Drupal administration theme" while Olivero is defined as a "Drupal front-end theme." Are these complementary themes? I'm not sure about whether I should install both - to have both a front-end and an administration theme or whether I need only one or the other. Any help you might offer in understanding the difference between a " ...

Score: 0
pglatz avatar
logging working on local site but not remote site
in flag

I recently migrated from Drupal 8 to 9. Works ok on my local (MAMP on Mac), but not on the remote (AWS Lightsail). Local has PHP 7.4.12, Remote has PHP 7.4.2.

I put the entire codebase in git, and pulled it to my remote server. I created settings.php for the remote host, set trusted_host_patterns, sites.php, .htaccess. I had a similar setup for Drupal 8 on the remote, which worked flawlessly.

Here's ...

Score: 1
etb5115 avatar
How does the config sync directory work exactly?
co flag

I just had a question quick about how Drupal's config sync works. I work on a large Drupal site where I am having some coworkers joining in on working on the project. It's a version controlled site where we develop locally on Docker and then pull changes to a web server.

I recently discovered that Drupal has a "config synchronization" feature. If making changes to the site (be it views, blocks,  ...

Score: 2
New To 'C' avatar
Block Settings inside Form
in flag

Please I need help with my code. I have a form and a block created programmatically. The block embeds the form to show it on the frontend. The block also has some settings (form preffix text). I want to load the block settings inside my buildForm in my Form.php to get the preffix text and show it in the form markup field. But I can't seem to find a way to pass on the $block_id to the buildForm() so it c ...

Score: 0
meh avatar
How to debug permission problems
th flag

I already found answers for older versions here and here but as far as I can tell none of it directly translates into drupal 9.

The matter in practice: I don't have a huge experience but I was very surprised when in the not so complicated setup I'm building I could see the page of a taxonomy term but none of the items in it under the introductory text when viewing the page as anonymous user. Viewing  ...

Score: 0
miststudent2011 avatar
How to add internal path in *
fr flag

I am trying to add an internal link to admin toolbar but I am not able to achieve it.

According to documentation we add an internal link in * in the below manner but the link is not being appeared in the toolbar.

  title: 'Hello module settings'
  description: 'example of how to make an admin settings page link'
  parent: system.admin_config_development
  url: interna ...
Score: 0
Creating a custom module caused "The website encountered an unexpected error. Please try again later."
mu flag

Drupal 9.2.7 on XAMPP 7.3.29 , 7.4.21 on Windows 10 Home.

I tried to create a custom module which allows global JavaScript and CSS (effective in all webpages in my website), by creating the directory root/modules/globalrs with the following files:

name: globalrs
type: module
core_version_requirement: ^8 || ^9
description: 'globalrs'
  - globalrs/globalrs


Score: 2
RitikaDesai avatar
How to automatically generate two aliases for the same node?
kr flag

I am working on a Drupal website. I need to automatically generate 2 url aliases for the same node on the website. I have tried installing Pathauto but it lets me generate only 1 alias when a new page is created. Is it possible to have it automatically create 2 aliases when the page is created?

Do we do this via the module itself or can we have this done by code?


Score: 1
Uploading local files via composer
bo flag

I'm using composer to manage a Drupal 9 instance. I'm brand new to composer and have no idea what i'm doing. That being said, I've successfully set it up and have used it to install modules and an admin theme. I just purchased a theme and realized that I don't know how how to upload it with composer. For modules and the admin theme I installed, I used composer require drupal/name-of-module(or theme) but ...

Score: 0
liquidcms avatar
Upgrading to Composer 2 blocked by Symfony dependecies
us flag

I have an existing Drupal 8.9.16 site which uses Composer 1 (and Commerce 2.24). I am trying to upgrade to using Composer 2 using this guide:

I have gotten through all the required steps up to the last step of dealing with drupal-scaffold ( ...

Score: 0
How to generate order pdf in drupal commerce and attach in hook_mail_alter
in flag

How to generate order pdf in drupal commerce and attach in hook_mail_alter using custom code. I trying another of method but seems not worked for me

Score: 1
Bohus Ulrych avatar
Place field in "Url Alias" advanced group section (path-0)
jp flag

I'm trying to place my node field to the Advanced group - URL alias section. I'm doing it in custom hook_form_BASE_FORM_ID_alter(), where I'm trying to set custom #group like this:

$form['my_filed']['#group'] = 'path-0';

But "path-0" neither "path_0", "path" works. But if I use something else e.g. "meta", "menu" ... then my field is displayed in right place. What's the trick to place it in "Url Alias" ...

Score: 0
Unable to upload files through RESTful services
us flag

I am trying to upload pdf files to webform submission using REST API.

Since the Core File Upload functionality did not seem applicable for webform submission, I applied the patch from webform_rest module which would allow uploading files for webform submissions.

When POSTing the file via /webform_rest/{webform_id}/upload/{field_name} with the necessary Content-Type and Content-Disposition, Cookie a ...

Score: 0
Attach PDF file to Drupal Commerce Order Notification generated with invoice commerce
ls flag

How do I attach a pdf file to the commerce email?

I have invoice commerce.

Invoice commerce show view pdf option on every order and I want to send that pdf in email

I am stumped on how to get the pdf into a File object.

module_name_mail_alter(&$message) {
 $my_attachment = array(
'filecontent' => $pdf,
'filemime' => $pdf->filemime,
'filename' => $pdf->filename,
'filepath' => ...
Score: 1
How can I bootstrap my site from an external script?
cn flag

Community asked.. Please clarify your specific problem...

Fair comment. What I'd like help with is how do I correct the script below so it works with D9.


use Drupal\Core\DrupalKernel;

$autoloader = require_once 'autoload.php';

// This next line is the problem
$request = Request::createFromGlobals();

$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');

$kernel->boot( ...
Score: 0
Drupal 9 core multilingual: cannot translate main navigation menu - button translate missing on menu items
cn flag

I'm trying to catch multilingual features of Drupal 9 and have wamp64 local development server and clean Drupal 9.2.8 install.

I've enabled 4 multilingual core modules:

  • Configuration Translation,
  • Content Translation,
  • Interface Translation,
  • and Language.

Two languages enabled: en and ru.

I'm trying to translate Main Navigation Menu, but menu items don't have a "translate" button along with "edit" ...

Score: 0
How to keep Contextual Filters (query) on Exposed Filter change
nl flag

I have a view page that leverages Contextual Filters with query parameters. So when a user visits the view page, the URL is as such… /search?location=san+francisco. This works as expected.

Now there are 3 exposed filters for this same view. When the user selects an exposed filter, the above contextual query parameters are replaced with the exposed filter parameters, as such /search?weather=cloud ...

Score: -1
Matoeil avatar
Migrating date into drupal datetime field
za flag

i am having the xml selector

<starting_date><![CDATA[ 2017-01-01 22:34:56 +0100 ]]></starting_date>

this migration process fails :

    plugin: format_date
    source: starting_date
    from_format: 'Y-m-j H:i:s Z'
    to_format: 'Y-m-d\TH:i:s'
    to_timezone: 'Europe/Paris'

How can i fix it ?

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.