Latest Drupal related questions

Score: 0
jackrabbithanna avatar
Update another line items quantity when line item updated
ke flag

Drupal 9, Drupal Commerce 2.26 I have an event subscriber, listening to CartEvents .. specifically CartEvents::CART_ORDER_ITEM_UPDATE

I have products of one type that reference products of another type.

The goal is when user updates order item for product of type 'class' in the cart, the order item for matching material_kit quantity is updated to match.

I have similar event subscribers, that allows me  ...

Score: 0
Søren Sjøstrøm avatar
How to find the cause of "Uncaught PHP Exception"
ru flag

When I go to any page, the following error appears in the log:

[proxy_fcgi:error] [pid 20333] [client 172.18.0.6:52608] AH01071: Got error 'PHP message:
 Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\MethodNotAllowedException:
 "" at /var/www/html/web/core/lib/Drupal/Core/Routing/MethodFilter.php line 46', referer: 
 http://example.dk.ddev.site/da

At first I thought it had something t ...

Score: 0
How can I set the label of a multiple image field programmatically
in flag

I have an image field with multiple images, field_sponsors.

I need to be able to set the label of this field programatically. The default label on the field is set to "Sponsors", but sometimes it needs to be labelled differently on output.

I've tried this in my .theme file in the preprocess_node function, but it does not work.

$node->set('field_sponsor', array(
      'label' => 'BATMAN!',
      )) ...
Score: 0
How do I make a custom multi-checkboxes field?
ke flag

By following the tutorials and documentation I am able to create a custom field that supports a single string value. However what I'd like to accomplish is a custom list (preferably the checkboxes type) where a user can select different options. I tried looking in core/modules/options schema.yml and copying the storage settings still gives me the same results. I get the error This value should be of the  ...

Score: 0
ilechcod avatar
How do I convert an action button to drop button?
in flag

I have my action buttons defined in my links.action.yml file and they show on the appropriate routes. But there's a page that requires 2 action buttons - Add Certification and Add license Since both buttons add something, it makes perfect sense to to have both on a dropbutton (like the operations button that shows on entity collection views). This is much better than having 2 separate action buttons side ...

Score: 0
Youssef HRIZI avatar
REST API 401 Unauthorized in user register JSON post
cn flag

I created a headless application using Drupal and Vue.js/Nuxt.js. I want anonymous users to register and Admin approves their subscription (the configuration for this is done).

I can't find a way to understand why. When I give the Access POST on User registration resource permission to anonymous users, I get a 401 Unauthorized status with the No authentication credentials provided. message using Pos ...

Score: 0
chalo avatar
Multiple unnecessary joins when creating an andConditionGroup()
de flag

I have a large array of names and surnames, I need to know which of these differ from the current ones in the database.

For example:

    $largeList = largeList();
    $storage = $this->entityTypeManager->getStorage("mi_entity");
    $query = $storage->getQuery();

    foreach ($largeList as $item) {
      $andGroup = $query->andConditionGroup();
      $andGroup
        ->condition('name', ...
Score: 0
Custom field formatter with blob, value always empty
lc flag

I have the following custom field:

/**
 * Plugin implementation of the 'price_table' field type.
 *
 * @FieldType(
 *   id = "price_table",
 *   default_widget = "price_table_widget",
 *   default_formatter = "price_table_formatter",
 * )
 */
class PriceTable extends FieldItemBase {

  public static function mainPropertyName(): string {
    return 'value';
  }

  public static function schema(Field ...
Score: 0
big_smile avatar
How to make the float field accept decimal values?
us flag

I am using Drupal 7 and have a float field. It is used to enter prices.

Most of prices I enter have decimals (e.g. 101.82, 99.88). Some of the prices are negative values (e.g. -55.52, -1009.88).

Sometimes when I enter a decimal value, Drupal will remove the decimal value. (E.g. 101.82 will become 101.00). Other times, it will keep the decimal value.

There doesn't seem to be any rhyme or reason as to wh ...

Score: 1
Sergey Kravchenko avatar
How to alter routes defined in route_callbacks?
in flag

Usually I alter static routes in routes subscriber:

  protected function alterRoutes(RouteCollection $collection) {
    $route = $collection->get('gutenberg.media.load_media');
    if ($route) {
      $route->setDefault('_controller', '\Drupal\gutenberg_adv\Controller\MediaController::loadMedia');
    }
  }

However I this does not work for routes defined in routes_callback, so this does not work ...

Score: 0
Entity reference to another instance of the same type
ai flag

Let's say we have a custom thing entity type, and we want to have a custom related_thing field in the entity which describes a relationship of some sort with other things. The custom field has several properties, indicating the nature of the relationship, when the relationship was recorded, who recorded it, and an entity reference to the other thing. As far as I can tell, Drupal won't allow setting th ...

Score: -2
Joost avatar
Change required state by checking checkbox
jp flag

I have an image field and a checkbox in my node edit form. I want the image field to be required when the checkbox is not checked. And I want the image field to not be required when the checkbox is checked.

How can I do this?

Score: 0
david avatar
How to return Service Worker with custom HTTP header from custom module
ng flag

I have a custom module providing a HTML5 Service Worker file under /modules/custom/my_blocks/assets/js/service-worker.js. Since the Service Worker is not located in the root of the Drupal server, I need to return the file with an additional Service-Worker-Allowed HTTP header.

How to do that within my module?

Score: 0
What are the steps for rebasing an issue fork of core to the latest code plus 'patch'?
cn flag

It appears the current version of Drupal outside the issue fork needs to be added as a remote repository, but i'm getting tripped up on creating it as a branch i can rebase against.

Hoping the answer to this is a link to documentation, but https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/rerolling-patches does not mention the issue fork workflow.

Score: 0
Jean da Silva avatar
Hook_install or hook_modules_installed save entity does not work
cn flag

I am trying to insert a new vocabulary to taxonomy because a custom entity from my custom module needs that vocabulary as an entity reference. I think it would be better to always insert the reference vocabulary to make it certain that it will always be there instead of doing it manually by the site.

The problem is the $entity->save() doesn't work neither in hook_install or in hook_modules_installed. ...

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.