Latest Drupal related questions

Score: -1
Why do I get "An invalid selection has been identified." from the form my code creates?
ng flag

I am using the following code for a form.

public function buildForm(array $form, FormStateInterface $form_state) {
  $region_options = static::getFirstDropdownOptions();
  $form['vvv_region'] = [
    '#type' => 'select',
    '#title' => $this->t('region select field'),
    '#options' => $region_options,
    '#empty_option' => t('- Select region -'),
    '#ajax' => [
      'callback' ...
Score: -1
Engin Yilmaz avatar
Sum the grouped results in the template
ng flag

I have an aggregated view result grouped by taxonomy terms and shown like the following.

TaxonomyTerm1
1
1
TaxonomyTerm2
1
TaxonomyTerm3
1
1
1

I want the result to be added and shown like the following.

TaxonomyTerm1
2
TaxonomyTerm2
1
TaxonomyTerm3
3

I tried to calculate the result in views-view-fields--reports.html.twig file with the following code.

{% set total = 0 %}
{% for field in fields - ...
Score: 1
chalo avatar
Correctly configure the JavaScript tools
de flag

I am trying to configure eslint for Drupal in PHPStorm, and it's really confusing.

For example, I have installed the node dependencies that comes in the web/core/package.json file. In PHPStorm, in the Eslint settings, I have configured web/core/node_modules/eslint, but with this module (eslint-config-drupal), I don't know if to configure it with node_modules/eslint which is in the root where I install ...

Score: 0
quantumized avatar
We need to check for and capture a URL parameter that may on any page so we need a efficient way to do this?
ng flag

We need to track some anonymous users coming to the site with a URL parameter, like "?utc=1234". This could be on any page though so I don't know what the most resource-efficient way to accomplish this is.

We are also using Cloudflare and Memcached so I don't know how this may affect anonymous users.

The use case is, upon a page load, to check if the URL parameter exists and, if it does, then save it t ...

Score: 0
ckojo avatar
Search API - Can't get result items
tm flag

I installed Search API, created Search Index, and it's using the Solr server. When I execute the query and debug the code afterward, I get 3 result counts. And for result items, I get an empty array. When I try the same query in Solr Admin, I get 3 result counts as well as result items.

public function searchResults() {
    $parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')
     ...
Score: 0
Travis avatar
Cannot update Group module with composer
cn flag

We are using the Group module on our D8 site. We use composer to manage our modules and dependencies. I am somewhat of a composer novice, so it's possible that the solution is right in front of me, but I cannot see it.

The Group module refuses to be updated. It's currently at 1.0, and I'd like to update it to 1.4. I've tried running a simple composer update drupal/group, using --with-dependencies

Score: 0
Ex0r avatar
Proper usage of config_split
cn flag

I am trying to use config_split so we can ignore/disable some modules/configurations on our dev environments, and we don't want them to carry over to our production environments.

I think I am setting things up wrong, as whenever I make config changes on my dev and push things up to production and import, it's overwriting the settings on production for modules we are ignoring in config_split. (For ...

Score: 1
KTM avatar
Modify sorting criteria using views_query_alter
fi flag
KTM

I have a view for the content type events with fields event_name, description, summary, event_start_date, etc. What my requirement is:

  1. Sort the events in ascending order of event_date equal or greater than the current date (upcoming events)
  2. Sort the events in descending order of event_date less than the current date (past events)

NOTE: the upcoming data should come first and then the past data.

Score: 0
Frank0051 avatar
Rewriting Start and End Dates in Views where Date is stored in single field
do flag

using Drupal 7, I have the Profile2 module installed. Within that, I have a field called "Employment Dates" and a user can enter a start and end date on this field. They can also leave the end date field blank.

I then have a view that has this field. It works well when there is a start and end date (for instance it will show Aug 2012 to Aug 2016 if that's the values entered) but when there is onl ...

Score: 2
fin avatar
Is the following code secure when saving data to database?
th flag
fin

I have a form that I want to save to database. Do you consider the following code safe? I get the value directly from the $form_state and pass it into query. My understanding, it query will do the safe filter for me.

       $db = \Drupal::service('database');

       
        $result = $db->insert('invitation')
        ->fields([
            'guest_email' => $form_state->getValue('emai ...
Score: 1
Giuseppe avatar
How can I delete a file served by a custom controller after it has been downloaded?
br flag

Starting from How do I create a file download URL? I've build a custom controller that allows users to download a PDF file.

my_module.routing.yml

my_module.pdf_link:
  path: '/my-module/pdf/download'
  defaults:
    _title: 'PDF download'
    _controller: '\Drupal\my_module\Controller\MyModuleController::downloadPDF'
  requirements:
    _role: 'authenticated'

MyModuleController

public function downloa ...
Score: 1
Adding a relative date range facet to a Search API view using the "last updated" field
cn flag

I would like to add a facet to a search_api view filtering on the content "changed" field. I would like to use friendly naming like "This week", "This month" etc. There is an answer here stating that custom code is needed. However this answer is for Drupal 6 (about 8 years old) and refers to a date range field while "changed" is a timestamp.

Currently if I add Date processor capability to this facet I h ...

Score: 0
Diana avatar
How can I customize the "H5P - Create and Share Rich Content and Applications" module?
cn flag

I need to modify the behavior of the H5P - Create and Share Rich Content and Applications module in Drupal 8, but (as far as I can see) there is a description of the hooks used from the Drupal 7 version of the module. There isn't a similar file for the Drupal 8 version.

What hooks should I use for the Drupal 8 version of the module? If the module doesn't use hooks, how can I customize the module?

 ...
Score: 0
Dimetry avatar
How can I disable these URLs?
cn flag

In Drupal 7, the following URLs show the same node.

This doesn't happen in Drupal 8.

How can those URLs be disabled?

Score: 1
Tobias Krause avatar
Remove a button from CKEditor based on the role of the current user
cn flag

I have a text format which should access by user role A and the admins but I only want the admins to see the "Source code" button. User's of the role A should not see this button but they should be able to use the exact same text format. Is there a way to achieve that without defining a new text format and handling all the text format during form building and entity saving?!

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.