Latest Drupal related questions

Score: 0
Extend Commerce api shipping methods response with custom fields
cn flag

With commerce api module, you can fetch all available shipping methods of an order with a GET request on {{host}}/jsonapi/checkout/{{cart_uuid}}/shipping-methods. Result is something like this:

    {
        "type": "shipping-rate-option",
        "id": "3--default",
        "attributes": {
            "shipping_method_id": "3",
            "service": {
                "id": "default",
                "la ...
Score: 0
cocq avatar
rebuild a form with ajax (solved)
gb flag

In a hook, I use ajax on a form field, designed with drupal user interface. It is declared as this :

$form['field_unite_de_recherche']['widget']['#ajax'] = array(
'callback' => 'ajax_equipes_from_unites_callback',
'event' => 'change',
'method' => 'replace',
'wrapper' => 'edit-field-equipe-membre2',
);

In the callback function, I retreive some values in the database from the selected value  ...

Score: 1
How can I receive and process form data submitted from an external site?
fi flag

I'm working on a CRM implementation in Drupal for a client and they have an existing website with forms on for people to make enquiries and so on. They would like the data submitted via those forms to automatically become entities in the CRM.

I could replace the forms with webforms from the Drupal site but that would be clunky, as they would have to either be in iframes, or users would be taken t ...

Score: 0
pierostz avatar
Module update with composer, updates module but not really
na flag

I am updating modules on my drupal site and I am using the composer like this:

composer require 'drupal/module'

The output I get from composer looks like everything is working fine but when I go to the update page of the modules nothing seems to change. The output from composer looks like this:

enter image description here

This is an occurence on every module I have.

composer.json :

{
"name": "drupal/legacy-project",
"descriptio ...
Score: 0
Stanley Fernandes avatar
How to use [node:title] token as filename for media type fields?
gt flag

I have a Drupal 9 site have two modules FILE (FIELD) PATH module and token is used.

So for a content type, one image field is there where in the File (Field) Path settings I have the file name as [node:title].[file:extension] and it works. https://nimb.ws/z8imjN

But when I add a media field, and go here admin/structure/media/manage/image/fields/media.image.field_media_image to add the file as [node:title ...

Score: 0
stckvrw avatar
Old GZ file is generated after editing CSS original
gb flag

After editing CSS file in the /sites/default/files/css directory I removed its GZ version and it's generated after a while, but with old CSS code.

How to edit CSS correctly? And how to force generating GZ immediately after editing CSS?

ps. Drupal 8.7.3

Score: 0
Gabriel Fernandez avatar
Avoid sending email (content moderation) when node updated programatically
cn flag

I have a csv import function which also will have to update the "moderation_state" field. Once csv import is ran, email will be triggered by content_moderation module. Is there a way to disable this when updating nodes programatically?

Score: 0
upgrade_status - unexpected error about PHP version
ru flag

I'm doing preparatory work for upgrading a site from D8 to D9...

The Drupal dev site (macOS 10.14.6 served with Laravel Vagrant) is running PHP 7.3.28, both on command line and php-fpm, and I'm seeing the correct version with php --version and at /admin/reports/status

And yet, whenever I scan my custom modules via the upgrade_status UI, I consistently get:

PHPStan command failed:

/Users/wt/Sites/sitename ...
Score: 1
Validation on custom entity edit form
lc flag

I have a custom entity where, instead of using the usual way of specifying edit form options with setDisplayOptions('form' and relying on ContentEntityForm to create my edit form for me, I have to make my own form in buildForm() (I have Ajax interactions between the fields that the stock from can't provide). It works all right, just that I can't trigger validation as with the stock form. The constraints  ...

Score: 0
stckvrw avatar
Class Drupal\dfm\EventSubscriber\DfmSubscriber not found when try to remove the Drupella File Manager
gb flag

I installed the Drupella File Manager module for Drupal 8.8, but I have Drupal 8.7. I received this error.

Call to undefined method Drupal\Core\File\FileSystem::scanDirectory()

I don't need the module anymore, so I'm trying to remove it. Because of the same error on the uninstall page, I'm trying to manual remove it.

First, I removed dfm (which is the module machine name) from the $module_data  ...

Score: 0
Unable to preview media items
kr flag

I have a node page where, in the WYSIWYG, I have embedded about 50 media items. When I edit the node, I can see this error for some of the media items.

An error occurred while trying to preview the media. Please save your work and reload this page.

In the browser console, the error is the following.

mysite.com/media/wysiwyg/preview?text=%3Cdrupal-media%20data-entity-type%3D%22media%22%20data-entity-uui ...

Score: 0
Override/remove title of view with contextual filter as a block
br flag

I have a block in a page that is a view with a contextual filter. As a block does not have a path, I have to provide a default value "raw value from URL" as per Contextual filter with a block view

This all works as it should, the view in the block gets filtered per the URL's last/third component as configured in the contextual filter's settings.

I use this block both in an overview mode where it shows al ...

Score: 0
Sergey avatar
Geolocation Geometry (Geometry) field cannot be edited in taxonomy term
us flag

I have a taxonomy type with Geolocation Geometry (Geometry) field type. I use custom Geolocation Geometry Lat/Lng to WKT widget (but the problem occurs with other widgets too).

The problem is that after filling in latitude and longitude and saving the taxonomy term I cannot change the field value anymore.

How to reproduce.

  1. Create a new taxonomy type with "Geolocation Geometry - Geometry" field ty ...
Score: -1
Monster971 avatar
Get the value of a field to do an if statement Twig
id flag

I am trying to generate a PDF with Entity Print. Until then all is well.

In my Twig page, I try to make conditional displays. But I can’t get the conditions to work.

I render my fields using {{ content.field_custom }} and that also works fine.

But the condition don't work , when I do something like :

{% if content.field_custom == 'John' %} ...

or

{% set field = content.field_custom %}
{% if field = ...
Score: 0
How can I avoid double line breaks (

) in a text field (field type: text unformatted long)?
ke flag

How can I avoid double line breaks (<br><br>) in a text field (field type: text unformatted, long)?

Users write text into this text field. When they hit Enter twice, the result is: <br><br>. But <br><br> is not themable with css, the height of <br> can NOT be set with css.

Therefore <br><br> should be avoided and paragraphs <p> used instead o ...

Score: 1
LeraA avatar
How can I customize breakpoints in USWDS base theme?
cz flag

I'm using the USWDS_base theme as a base for my custom theme. Version 8.x-2.10

In this file: web/themes/custom/my_child_theme/sass/_uswds-theme-utilities.scss I find the tokens used for the breakpoints (see screenshot).

In the comments, I can see what size those tokens represent. I can't find anywhere where those numbers are set so that I can override them. I've been combing through the theme for h ...

Score: 0
Sidney Sousa avatar
How to add index to paragraph template
af flag

I want to use paragraphs to implement a carousel, and for now, I have the outer paragraph called slideshow, and the template is paragraph--slideshow.html.twig. Then, inside this paragraph, I can add slides, and the template is paragraph--slide.html.twig.

At the moment, I only have the default paragraphs template which looks like this:

{%
  set classes = [
    'paragraph',
    'paragraph--type--' ~ par ...
Score: 0
Adi avatar
Show pop-up form after every drag and drop
um flag
Adi

I'm working on functionality based on the Homebox module. Whenever a drag and drop operation is performed, I want to show a form in pop-up. Does anyone have experience with it?

Score: 0
Extect avatar
With sites/default/files not part of the git repo, which content will be used in dev?
cn flag

I am using a composer managed Drupal install and want to use git to move it between development and production environments. From what I understand, the only directory that is not supposed to be in the git repo is sites/default/files. Everything else incl. modules, themes, composer files etc. would be in the repo. Composer would only be run in local dev, but not in production.

What I don't unders ...

Score: 0
How can the Webform element Form display defaults be set?
cn flag

Every webform element has a little section like this:

Form display section with Title display, Description display, and Help display all set to " - Default -"

Where can one set these defaults, for Title display location, Description display location, and Help display location?

It does not appear to be in any of the webform overall settings or webform specific settings.

If it's the default for the element type, is there a programmatic way to override the default (but not if set for an individual ele ...

Score: 0
H M avatar
Integrating jQuery Auto Height with Views Infinite Scroll
mw flag
H M

I have a views block with an infinite scroll (using Views Bootstrap and Views Infinite Scroll modules). The block displays cards and I want them to have the same height. jQuery Auto Height does that well. However, it only happens for the initial load. Auto Height has no way of knowing to fire on subsequent Ajax calls. What is the best way to integrate them so that Auto Height is called on each infinite ...

Score: 0
Josh avatar
Underscore JS Not Loading
yt flag

I am writing code that uses Underscore JS in Drupal 9 that should be loaded from /core/assets/vendor/underscore.

I am using Chrome DevTools to see the sources and though jquery, jquery-once, and modernizer are all loading from /core/assets/vendor/ the underscore library is not.

I am almost positive that this was working last week. I have updated my code since then but it is the same use of underscor ...

Score: 0
peterbe avatar
FillPDF not displaying 'foreign' characters
in flag

I'm using the fillpdf module with the online FillPDF service to render the PDFs. Most everything is working great; however, if a database field I'm displaying on the PDF contains certain 'foreign' characters, those characters don't display at all.

Notably, this occurs with the circumflex (ĉ) and caron (č) characters. Other foreign chars display fine (eg ö, é, è ...).

Not sure if this is an issu ...

Score: 0
Managed_file with table of uploaded files
lc flag

Adding a file field to a custom node type results in a nice UI with a table appearing for all uploaded files, with a Remove button for each. But simply adding a managed_file to our own forms, eg:

$form['attachments'] = [
  '#type' => 'managed_file',
  '#title' => t('Attachments'),
  '#description' => $descriptions,
  '#upload_validators' => $validators,
  '#upload_location' => $this->get ...
Score: 0
Gabriel Fernandez avatar
How to handle large queue process
cn flag

I'm using the QueueWorker plugin to do some update/create node process in the background. On local there isn't an issue, it completes the whole queue process. However on the aws server it usually stops at some point. I'm assuming because of the resource consumption on the server. Whats the ideal way to optimize my QueueWorker?

Here is my code:

$offset = 0;

while (TRUE) {
  $nodes= \Drupal::entityQuer ...
Score: 0
steevee666 avatar
How to replace the default page and tab of profiles in the user account?
in flag

I installed the "Profile" module on my "Drupal 9" website. When I create a profile type, the module automatically creates a tab in the user account for each profile type.

For my profile type "projects" the user account tab displays the page for this profile type, with this path :

/user/ID/project/list

Here is the view added by the module :

enter image description here

Here are the tabs created in the user account :

enter image description here

I created ...

Score: 1
matsbla avatar
How can I provide my own replacement patterns to be used in config form?
pe flag

I want to give a configuration form where user can configuration text on a widget, like the description and button label, however I want to provide a replacement pattern to be used, like {{count}} so the user can write for instance "{{ count }} images remaining". How can I provide replacement patterns to be used in the configuration form?

Score: 1
Grayson Cooper avatar
Git branching strategies with a small team to develop a Drupal site
in flag

We're a small team (5-6 developers) building a Drupal 7 site. Previously, we've used Features (https://www.drupal.org/project/features) to export our configurations from development to production. We've relied largely on assigning developers discrete, unrelated tasks.

Our upcoming work has distinct, but related development. For example, I anticipate we'll need to add fields that will be used by two d ...

Score: 2
Rubix05 avatar
Shared Facet between Taxonomy and Content Field
cn flag

My search page needs to show results from both content types and taxonomies.

Both the content type and taxonomies that I am searching on have a field called training_location. The training_location field is also a taxonomy with only two options: "Remote" and "In-Person".

Is there a way to merge a facet so that I can filter results for both a content type and taxonomy that has the training_location ...

Score: 0
J.g avatar
How can I view the list of referenced nodes when viewing a node?
us flag
J.g

I have a content type with a Related pages field, which an entity reference field for nodes.

How can view those nodes while still on the current node?

I tried to achieve this by creating a block view, but this shows all the nodes, whereas I want only the nodes referenced by the Related pages field.

screenshot

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.