Latest Drupal related questions

Score: 1
jreinholdt avatar
Migrate + JSON:API node references to entity type references aren't mapping
ke flag

I have successfully migrated nodes from a D9 source site into a a custom entity type (RedHen CRM contact) on a target D9 site. Next, i am trying to migrate taxonomy terms with a multiple reference field from the source site into nodes of type 'networksn21' on the target site using the first migration. I am using the following yml file for the second migration:

source:
  plugin: url
  data_fetcher_p ...
Score: 1
nschildre avatar
FieldStorageConfigStorage::loadByProperties() with multiple conditions doesn't return any result
ng flag

Using FieldStorageConfigStorage::loadByProperties() with the entity_type and sid (from webforms) as conditions doesn't return any results. I can get a result if I run each of the conditions separately. Could be related to this issue, but I am not sure: https://www.drupal.org/project/drupal/issues/2917606. How can I fix this issue? If I need to write a repository service for this how do I do that?

 ...

Score: 0
Ajax call brings all the Javascripts of drupal ruining the original page javascript
it flag
MMT

Based on this solution https://www.drupal.org/docs/7/api/javascript-api/simple-drupal-ajax-load-with-jquery-and-delivery-callback I'm brining with an ajax call, a multistep form. The ajax brought multistep needs ajax as well to execute the steps in between of the multistep form.

The above link advises to use this model of call back function

function myModule_ajax_callback($page_callback_result) {
  ...
Score: 4
user109436 avatar
Why doesn't cweagans/composer-patches install my custom patch for drupal/slick?
ug flag

Basically, I have installed slick module and customised code and created a patch file using "git diff" command. Slick module file path is modules/contrib/slick/ directory. Below is the code that i have written in the composser.json file.

"require": {
        "drupal/slick": "^2.7",
}

----------------------------------

"patches": {
  "drupal/slick": {
  "Slick custom changes": "patches/slick/slick.patch ...
Score: 0
How do I enable all error messages altering directly a database table?
US flag

When I try to log in on a site, I get a generic error, which doesn't help in understanding what exactly is going wrong.

I would like to enable the All messages, with backtrace information option shown for Error messages to display, to be able to understand what the error cause is.

Is it possible to change it by directly altering a database table? If the answer is yes, which table and which row should I ...

Score: 0
sudhan avatar
"Composer\InstalledVersions" not found in Solarium\Client::getVersion()
us flag

When i try to open configuration page of search API module i am getting the below error:

The website encountered an unexpected error. Please try again later. Error: Class "Composer\InstalledVersions" not found in Solarium\Client::getVersion() (line 59 of vendor\solarium\solarium\src\Client.php).

I have checked the place where it is stating error but it is updated as per the recent package.

use Composer ...

Score: 0
Were sub-menu lists of admin panel deleted?
US flag

I installed Drupal 9.3. In its administration panel, I don't see drop-down sub-menu lists I saw in a Drupal 8.9 site, where I could hover the cursor at any of the first level menu items (for example, Content or Structure).

Has sub-menu lists of the administration panel been removed in Drupal 9.x?

Score: 0
Shane avatar
Unable to add custom css from asset injector module to content type
gu flag

I have a content type called Advertisement on my Drupal site. I want to add some custom css functionality to this content type (as in, when I create an advertisement from the "Add Content" button, it should have the css I want).

I am using the Asset injector module to insert the css. Here is what it looks like: enter image description here

These are the conditions I have specified in the injector:

enter image description here

However, if I try to creat ...

Score: 0
Matt avatar
How do I create a paragraph using a bundle class defined in another module?
cn flag

I have a controller in one module that generates paragraphs that are using unique bundle classes that I want to be able to use in other modules.

In my controller I have this

$bundle_class = \Drupal::service('class_resolver')->getInstanceFromDefinition('Drupal\other_module\Entity\Paragraph\StandardHero');
$paragraph = $bundle_class::create([
  'type' => 'standard_hero',
  'field_title' => [
   ...
Score: 1
tim avatar
Why the form does not save data from the entity reference field?
qa flag
tim

I have a custom entity (with the name Entity Quote), from the add form of this entity I make a multistep form.

In the custom entity Entity Quote, I added another custom entity (with the name Quote Design) as a reference field(with the name Design) to add the form of the second custom entity Quote Design to the second form step of the first custom entity Entity Quote. And I implemented adding the form of  ...

Score: -1
Souvik Das avatar
How will I highlight active item in glossary view?
rs flag

I have created a glossary view which shows alphabetical navigation to filter the list.

But I can't find a way to highlight the active link - would like for "G" to be highlighted if I am clicking the "G".

I have this tutorial for this but it works only when ajax is disabled. But I am using ajax for this glossary view.

Below is the code which isn't working

$(".view-display-id-attachment_1 span a").each ...
Score: 4
Vishal Kumar Sahu avatar
Does CKEditor5 have an embed button like CKEditor4?
bd flag

With CKEditor4 I was able to configure the editor to have embed buttons for entities (Webform, Taxonomy, or Node) like this using through Configurations >> Content Authoring >> Text editor embed buttons.

CKEditor 4 supports Entity embed

With CKEditor5, I am lost as it has only Drupal media embed.

CKEditor 5 with no Embed option except drupal media

Note: Merely changing CKEditor4 to CKEditor5 is not breaking existing functionality as of now.

How can I get Entity Embed but ...

Score: 2
greggles avatar
Allow users to upload heic images and auto-convert to jpg
ru flag

It seems that heic images are increasingly popular way to store images (the default image format since ios 11, but browsers do not support them. Site visitors may attempt to upload an heic image from their phone to an image field, but the default file extension validation prevents that. If a site admin allows heic file extension for the field then the file can get uploaded, but is not displayed as an im ...

Score: 1
flauschi avatar
Can we export json schemas for type script usage?
fr flag

We have a Drupal installation that acts as a backend and a front end that uses the HttpClientModule from Angular to query this data.

Thanks to the typescript base, we can provide the functions of this service with the expected return type like this.httpClient.get<ExpectedTypeInterface>(urlToJsonResource). The important question is: Where does the implementation of the ExpectedTypeInterface c ...

Score: 0
bburch2000 avatar
Why don't I see Asset Injector code directly in the HTML?
bd flag

I’m having trouble getting the Asset_Injector module to work, and would like to find out why it's not working.   As a simple test, I want to insert some CSS using the module’s CSS injector:

#container {
    max-width: 1000px;
    margin: 1em auto;
}

Asset_Injector is configured with no restrictions on injection:  content types, pages, etc. But when I create a page, then look at the source cod ...

Score: 0
Possible to fallback to a simple text format
ve flag

We have to Textformats for the WYSIWYG editor:

  • full html (intended for admins with html knowledge)
  • simple html (for the non-tech editors)

Both can edit the node

However, if the admin save a field with full html, it is automatically blocked for the normal editors, as they have no permission for the "full html":

enter image description here

Is there a way, that the field is simply using "simple html" as fallback? It would be no pro ...

Score: 0
Change default value when triggering form #states
kn flag

By default, my field_taxo has the value 'castle'.

  1. _none
  2. castle (by default)
  3. mansion

The field_taxo is only showing when the role 'marketing' is checked, and becomes required.

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
  $forms = ['user_register_form', 'user_form'];
  if (in_array($form_id, $forms)) ...
Score: 2
quantumized avatar
Is there a way to retain core search logging instead of having it get deleted with the watchdog logs?
ng flag

We're using the core search module on a D9 site and use the "Top Search Phrases" report for search tracking but the results get stored in the watchdog table so they get cleared out when the logs do.

I see there are some D7 modules to improve the core search logs but nothing that I could find for D8.

The client needs to retain the search word logging so how could we do this on our D9 site?

Score: 0
liquidcms avatar
How to programmatically capture a payment?
us flag

Payment is in Authorized state. How do I programmatically capture it? I am using Authorize.net payment gateway.

Score: 0
Francesco Marchetti-Stasi avatar
Empty node references on node creation and on node load
iq flag

I never noticed it, but:

  • If I create a node containing a reference and set the reference field to null, the field is still set as an EntityReferenceFieldItemList, e.g. the following code
echo "Creating a node with ref_field=null", PHP_EOL ;
$node = Node::create([
    'type' => 'my_type',
    'uid' => \Drupal::currentUser()->id(),
    'title' => "title",
    'field_ref_field' => nu ...
Score: 0
oneindige avatar
Problem with PHP version on Ubuntu on Windows when installing Drush
ke flag

I'm trying to install Drupal 10 with DDEV with these instructions: https://ddev.readthedocs.io/en/latest/users/quickstart/#drupal. I'm on Ubuntu on Windows (WSL2). Ubuntu version: 20.04. Windows 10. When I try to run the command ddev composer require drush/drush I get errors.

Using version ^11.4 for drush/drush
./composer.json has been updated
Running composer update drush/drush
Loading composer  ...
Score: 4
How to add an item constraint to a field
ke flag

How do I define an item level constraint, as opposed to a constraint on an item list?

In the comments of \Drupal\Core\Field\FieldConfigInterface, there is this note:

   * If you wish to apply a constraint to a \Drupal\Core\Field\FieldItem instead
   * of a property or FieldItemList, you can use the
   * \Drupal\Core\Field\FieldConfigBase::getItemDefinition() method.
   * @code
   *   // Add a constrai ...
Score: 0
Drush fatal error with Declaration of Drupal\Core\Logger\LoggerChannel::log
in flag

When I run any drush command or even just drush I get the fatal error:

Fatal error: Declaration of Drupal\Core\Logger\LoggerChannel::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerTrait::log($level, Stringable|string $message, array $context = []): void in /core/lib/Drupal/Core/Logger/LoggerChannel.php on line 94

I updated drupal with composer to 9.5 and I'm running PH ...

Score: 0
Nasser Ali Karimi avatar
Twig custom filter return cached value
in flag

I have a custom filter for the twig, but the value of the filter doesn't update. It remains the same till clearing the cache. I want to get the url param and based on the value showing different output in the twig template. Here is the custom twig filter

class CustomTwig extends Twig_Extension {
    
  public function getFunctions(){
        return [
          new TwigFunction('link_to_requirement',  ...
Score: 0
Kartagis avatar
How to import config to a site installed with a profile?
lu flag

Good day. I’ve installed a profile, made my settings, entered my content, exported config and pushed everything to the repo. Now, when I clone it somewhere else and attempt to install using the config, I get a lot of these entities need to be deleted first errors, along with others. Is there an easier way than either going to the UI and deleting the said entities one by one or going with drush edel &lt ...

Score: 0
Smartsheet eng avatar
Modifying a view runtime?
um flag

I wanted to remove click sort from a view and couldn't find anything. So I tried to force:

<?php

/**
 * Implements hook_views_pre_view().
 */
function sd8_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  if ($view->id() === 'content' && str_starts_with($display_id, 'embed') && \Drupal::routeMatch()->getRouteName() === 'entity.user.canonical') {
    $ ...
Score: 0
liquidcms avatar
How to distinguish between order.paid event when authorization/capture and just capture?
us flag

I asked this question back in 2020: How do I programmatically "place" an order? and provided my own answer there:

Provide an event subscriber:

  public static function getSubscribedEvents() {
    $events['commerce_order.order.paid'][] = ['placeOrder'];
    return $events;
  }

which then applies a transition to the Order:

 public function placeOrder($event) {
    $order = $event->getOrder();
     ...
Score: 0
Rico avatar
How can I print the link to the media file?
th flag

I have an image media type. I would like to display the image and the link to the file in the rendered Media. I don't want the image to be a link to the file.

I couldn't find a link to the file field in Manage display. I looked at the media.html.twig file, but I could not understand how to link to the file.

How can I add the media file link in Manage display?

{#
/**
 * @file
 * Default theme impl ...
Score: 1
Matt avatar
Is there a way to specify order in a search_api query manually given a set of node ids?
cn flag

Using search_api I have an query with the following condition

$query->condition('nid', [1,5,3,7,10], 'IN')

I know I can sort by things like created date or title, but what if I knew the exact order I wanted everything returned in. So in the above example where I'm grabbing the nodes with ids [1,5,3,7,10] what if I want the results returned in that order too. So after executing in the array of resul ...

Score: 2
thiokol avatar
How can I populate radio options on a form with user entities?
cn flag

I have some user entities and I want to make them available as options to choose in a radio button element on a form.

I can populate the options with a username no problem, so visually I can achieve what I want, but I need to be able to get the user entity that was selected in the form submit function, not just the user name.

I've tried loading the entire user entities into the options array but thi ...

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.