Latest Drupal related questions

Score: 2
Kevin avatar
Is there a way to restrict time zone options in the DateTimeRange field widget?
in flag

Is there a way to limit the options of the timezone field in the datetime or datetime range widget in Drupal 8? It currently shows tons of timezones, but we really only need about 10 options. I checked the default widget but did not see anything about how it was building that part of the widget form.

The core DateTime element appears to do:

$element['timezone'] = [
        '#type' => 'select',
     ...
Score: 0
Giuseppe avatar
How get the info of a element in webform email twig?
br flag

I'm on D9, theming a webform email.

I'm currently overriding the twig file, instead of using the configuration of the body in the email hanlder, because there are various conditional logic I've to check - e.g. if interface language is en print element a otherwise element b.

To create the required markup, I need to get the info of the elements: for example, for select elements, I need the label and the t ...

Score: 0
Populate a node form field's select options from a view output (values only)
nl flag

I'm looking to populate a node form field's select options (not sure the type of field to use) with values from a view output? I know Entity Reference field has that option... but it forces you to choose a single entity as the selection. I have some single entities that would provide multiple values to that view output. Any tips? Thanks!

Score: 0
Filling in default value for datetime field in custom entity
de flag

I am trying to set the default value for the date field in a custom Entity. The code does not produce any errors. The date field does just not populate with any value. How can I set the default value?

enter image description here

   $fields['date'] = BaseFieldDefinition::create('datetime')
      ->setLabel(t('Date'))
      ->setDescription(t('The date of the entity.'))
      ->setDefaultValue('2021-09-09')
  
       ...
Score: 0
A theme in a custom distribution isn't found
kp flag

For our Drupal sites we develop our own distribution. In the distribution are two themes (administration theme and custom base theme). The administration theme works, but the custom base theme cannot be found. When I try to install the theme with drush theme:enable our_base_theme -y, I get this error.

In ThemeInstaller.php line 136: Unknown themes: our_base_theme.

In admin/appearance, under the cust ...

Score: 1
Павел Герасюта avatar
Change langcode
br flag

How can I change the entire site <html lang="en"> to <html lang="en-US">? I couldn't find anything on the Internet.

Score: 0
Jewel Chakraborty avatar
How can the custom files copied by code to the private directory be accessible through URL for authenticated users?
us flag

In my project, I am using headless Drupal with .Net on the front end.

I have to use private and encrypted file systems for the project requirements. The files which I am uploading through Drupal private file field from content type are accessible through URL, but as encrypted files aren't accessible through direct URL, I thought of copying the decrypted files from the encrypted folder to the priv ...

Score: 2
How do I fix the base URL issue while using load balancer
hk flag

Since base URL is deprecated, and our Drupal 9 Site is using a load balancer, we are facing issues when setting up the base URL. Instead of the base URL, it displays the load balancer IP.

Any help regarding the issue is appreciated.

I made the following changes to the settings.php file.

$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);
$sett ...
Score: 0
What is a good way to send out email notifications on creation of a new entity?
hk flag

I was trying to see what is the best way to handle customized notifications around the Website Feedback module. The module creates a new entity of type WebsiteFeedback (a custom entity defined by the module) whenever a user submits feedback using the module

I see Entity Notifications module but that does not seem to have a Drupal 9 release.

Is there something ready for Drupal 9?

Score: 0
Frank6 avatar
EventSubscriber to add cache context for specific path
cn flag

I am working with Mobile Detect module and from what I understand, we need to manually add the cache context mobile_detect_is_mobile in order to have the page cached differently based on the user device type. I was able to make it work by applying the cache context using a preprocess on my paragraph like so :

function hook_preprocess_paragraph(&$variables){
    $variables['#cache']['contexts'][] = 'mo ...
Score: 0
Can't open url link or images in CKEditor on a modal form
ni flag

I have created a custom form with a text field that uses ckeditor. I open this form in a modal window. It works good, but if you try to use url link button or image button, because they are opened in a modal window too, my form disapears.
I open the form using this code:

var ajaxSettings = {
            url: '/' + path + '/' + id + '/edit',
            dialogType: 'modal',
            dialog: {classes: { ...
Score: 0
Simple sitemap news are always in pending state?
in flag

To site that is using Simple XML sitemap I installed Simple XML News Sitemap module. Basically I cloned all the setting form existing sitemaps. Also configured article content type to use new site map variant. Problem is that Status page (/admin/config/search/simplesitemap) those new variant for news sitemap type are always in "pending" state. I do have articles with this sitemap variant set, I was reb ...

Score: 0
How to configure a custom POST api to accept a request with Content-Type as "application/x-www-form-urlencoded" in the header?
bw flag

I created a controller in a custom module that accepts a POST request.
I have a setup such that I get a POST request from a third-party application server to this API. But the POST request has a Content-Type: "application/x-www-form-urlencoded" in the header.
And because of this I get the following error in the recent log messages:

Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException ...

Score: -2
Md. Shafiq Hossain avatar
How to open a form in modal from controller while redirect
cn flag

I can open a form in modal when click on a link (and there are lot of examples in the net as well).

What I like to do: When some one go to a url in browser or redirect to a url, it will open a dialog/modal form.

-I have defined a controller for a url -In the controller function I placed the code like this:

  $response = new AjaxResponse();
  $title = $this->t('Confirmation');
  $form = $this->formB ...
Score: 0
Ex0r avatar
Views Bulk Operations - Custom Action Functionality
cn flag

I am working on functionality that allows a user to view a list of inventory copies, and a custom action to 'bulk print barcodes'.

I am using Views Bulk Operations.

I created the custom action for VBO, and use the executeMultiple() to generate the barcodes into a pdf, but I can't send the PDF to the browser for viewing/download.

I downloaded the 'export to csv' custom action for VBO to take a look at i ...

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.