Latest Drupal related questions

Score: 1
Programatically create paragraphs entity form
fr flag

I am in a situation where I would like to split out Paragraph entities to separate forms.

Edit forms are no problem:

$entity = Paragraph::load($entity_id);
return \Drupal::service('entity.form_builder')->getForm($entity);

But how do I get the create form? So far I have this:

$entity = Paragraph::create();
return \Drupal::service('entity.form_builder')->getForm($entity);

... but the information ab ...

Score: 0
Mira chalak avatar
Translation of a video URL
eg flag

I have a content type Book with a field called demo that references to a media (remote video - we must provide a youtube URL). As a first step I create a new node in french and I put a youtube URL ex: www.youtube.com/abc and I save. then I add a new translation to english and I put another youtube URL for this demo field ex: www.youtube.com/zyx. Now when I go back to the firstly created node in fr ...

Score: 0
aljico avatar
Is there any possibility to capture an array with all nid of a view?
mx flag

I tried using hooks but in $view->result variable I only get nodes from the actual page (10 nodes because pager size is 10). My view has multiple exposed filters so I want the resulting nodes from filtering

function mymodule_views_pre_view(&$view, &$display_id, &$args){

if ($view->id() == 'myview') {

    foreach ($view->result as $row) {
        // Get the full name value.
  ...
Score: 0
Павел Герасюта avatar
Form with ajax and javascript problem
br flag

I re-create the question with more accurate data (Original question Form with ajax and javascript problem). I have a button in my form that generates a fieldset via ajax. When I try to track this button being clicked with jQuery, it just doesn't see this button.The button id is shown below.enter image description here I tried to keep track of using just an input as a selector, it still does not work. Javascript is exactly connec ...

Score: 1
quantumized avatar
How can I create a simple dropdown to allow users the select an attribute (like ring size) from a Commerce 2 product page?
ng flag

This seems like it should be simple but despite reading docs and watching videos I cannot figure this out.

I have a Commerce 2 product variation type that I need to add a dropdown on to allow users to select a ring size. This will not affect the price.

I've been trying to use attributes but it doesn't seem to work correctly.

I've created a new attribute type (Ring Size) and add the sizes to it. But the ...

Score: 0
How can I add a billing and shipping field?
cn flag

In the Drupal 7 version of Ubercart there was the very helpful Extra Fields Checkout module but for Drupal 8 there does not seem to be an alternative.

How can I add a billing field and shipping field to the checkout form?

Score: 0
Send hook preprocess_views_view results to custom form or services
pe flag

I am developing a feature that allows anonymous users to receive by email the result of a facets + searchAPI.

Facets and Search API work perfectly. The custom module that allows to send an email too. I have also created a custom form (FormAPi) to let user gives its mail and send the datas on submit.

To get the results of the facets search, I use the preprocess_views_view in .module file

function  ...
Score: 1
Dorian Winterfeld avatar
Why isn't the Highcharts library, defined from a custom module, loaded in every page?
ae flag

I am running Drupal 9.1.7 on lando on a Mac. I am writing a custom module and I want to include the Highcharts library. The .libraries.yml file looks like this.

stats_degrees:
  js:
    https://code.highcharts.com/highcharts.js: { type: external, minified: false }
  dependencies:
    - core/jquery

From reading the documentation, I believe I should see the Highcharts library at the bottom of every pag ...

Score: 0
devnew avatar
file upload required asterisk symbol get removed after upload file
gh flag

I created a file element in a webform and set it required in condition that if select element (name as request type) value ="Yes". So when I select type value 'Yes' the file label showing asterisk symbol Attachment * but when I upload an file the asterisk symbol get removed and label become Attachment only. In case if i submit the form asterisk symbol appears as well. Can anyone having same issue and f ...

Score: 1
hank avatar
Error when updating translated content
mx flag

I have fought for some time with the error below:

Non-translatable field elements can only be changed when updating the original language.

I have "inherited" a site a few years ago and been updating it so it's D8 up-to-date (8.9.16).

When the user tries to save a change in language version of a page (on many but not all pages), she gets the aforementioned error message (even if not changing anyt ...

Score: 0
Gabriel Fernandez avatar
Optimize fetching data from entity objects
cn flag

Currently we are using EntityTypeManager to either load or loadMultiple :

$this->entityTypeManager->getStorage('node')->loadMultiple($nids);
$this->entityTypeManager->getStorage('node')->load($nid);

This creates and returns objects of nodes which I think uses much resource on the server (since it fetches all fields). We're also trying to fetch around 500 nodes, and each has over 80 fie ...

Score: 0
Darcy avatar
Connect React/AJAX to custom module
cn flag

I am trying to create a mini-CRUD component on the Drupal 8 site. I am fetching data from an external source, and rendering it using ReactJS.

I wish to update the database when a user clicks a button in the React component.

<button
    onClick={() =>
        $.ajax({
            type: "POST",
            url: "../path-to-file/script.php",
            data: { id: 'some data' },
        })}
&g ...
Score: 3
Jaypan avatar
No results behavior not showing on a view
de flag

I have a view, and the no results behavior is not showing even when there are no results. The view shows all nodes tagged with the same term as the current node.

This is done with two relationships

  • One from the node to the taxonomy term
  • Another from the taxonomy term back to the content type

And two contextual filters

  • One on the node connected through the two relationships, to filter for all nodes ...
Score: 1
Jaypan avatar
Create a view showing all nodes tagged with the same term
de flag

I'm trying to create a view that shows all nodes tagged with the same term as the current node. Note that the field only allows a single term. So each node (of this type) will only have a single term (of this vocabulary) attached to it.

I have a node ID in the URL for my contextual filter. I cannot figure out the right combination of relationships and contextual filters to show only nodes that ha ...

Score: 0
quantumized avatar
Is it possible to make a managed_file field drag and drop?
ng flag

I have a single-value managed_file field on a custom form in Drupal 8 that I need to make drag and drop.

I don't want to use another field type like dropzonejs because I have a complete complex workflow built using the managed_file and switching the form's field type breaks a lot of functionality.

Is it possible to somehow allow the existing managed_file field to have drag and drop file functionalit ...

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.