Latest Drupal related questions

Score: 0
Monster97139 avatar
Submit webform via custom button
cn flag

I want to update a webform submission via custom button.

On the same page as my webform I created a custom button in a block.

 <button id="myButton" onClick="submitWebform()" type="submit"> Click here!  </button>

with JS code

 function submitWebform() {
       document.getElementbyId("webform-submission-id").submit();
 }

But when I click on the button the page reloads but my webform is not  ...

Score: 0
CocoSkin avatar
How do I set the custom Gutenberg font size?
cn flag

Mythemename.gutenberg.yml allows setting custom font size, but it doesn't work on Drupal 9. (It works on my old Drupal 8 site.)

Basing on Creating custom font size presets in a Theme, custom font sizes could be added in the .gutenberg.yml file for the theme.

The colors appear on the Gutenberg with the following settings, but the "Mega" font size doesn't.

Mythemename.gutenberg.yml

theme-support:
   ...
Score: 0
LeJuanChis avatar
change taxonomies link
pa flag

I have a problem and I want to modify the link of a taxonomy but I don't know how. For example, I want that when I click on the taxonomy "news" it takes me to the url "magazine/categories/news", when I click on the taxonomy "economy" it takes me to the url "magazine/categories/economy". I tried with pathauto, but the url "magazine/categories/news" is already created, and it doesn't let me modify it. Doe ...

Score: 0
SI_2000 avatar
Composer upgrade to 9.4.x fails, my site is stuck on 9.3.x
tz flag

My Drupal 9 site is stuck on the 9.3.x track, I cannot upgrade to 9.4.x. If I use the standard upgrade command:

composer update "drupal/core-*" --with-all-dependencies

Then it upgrades to the latest 9.3 version (currently 9.3.22), but no further.

If I try to force to 9.4.7 (or any 9.4.x version) with:

composer require drupal/core-recommended:9.4.7 drupal/core-composer-scaffold:9.4.7 drupal/core-proj ...
Score: 0
lee avatar
Auto send userA's profile URL to userB
cn flag
lee

I thought this could be easy, but I don't know what's the best way to achieve this.

I have an acting "job" application site, userA need to finish his "profile2" first which including photos, weight, height etc.. userB will post a job node, then userA will click an "apply" button within the job node, userB will receive a message/email which including the userA's profile URL, then userB can look a ...

Score: 1
Francesco Marchetti-Stasi avatar
What cache service should I use?
iq flag

I just used a cache service explicitely for the first time, in a function that calls a remote service. The result is a simple string that may change day by day, but it's very rare that it changes for the past – so I expire it at midnight.

I injected cache.default in my controller – then I saw that in core services there is also a service called cache.data. What's the difference? Is there any reas ...

Score: 0
kankari avinash avatar
I need to send a mail from my custom module if there is any update in webform
td flag

I have to implement a custom module where I need to send a mail if there is any update in webform. I cannot use Rules Module.

For example, there is an option field(drop down) in webform, where value of option field is changed from name_1 to name_2. I need send mail to name_2.

So, what kind of Hook function i need to use? should I use Hook_webform_element_alter() or Hook_webform_option_alter() or not ...

Score: 3
hotwebmatter avatar
All routes resolve to entity.user.edit_form for authenticated users
nr flag

This is a new one for me:

All routes, for an authenticated user, resolve to entity.user.edit_form.

Anonymous users are able to browse all public-facing pages of the site without any problems.

This is the route:

$ ddev drush core:route --name=entity.user.edit_form
name: entity.user.edit_form
path: '/user/{user}/edit'
defaults:
  _entity_form: user.default
  _title_callback: 'Drupal\user\Controller\UserCont ...
Score: 0
Lambic avatar
Link render array style attribute getting stripped in event subscriber
ph flag

I'm trying to generate a link as part of a string which will get sent by email. The link has to be styled to look like a button.

I'm doing this in a token event subscriber.

Here's my current code:

$url = Url::fromUri('https://google.com');
$link = new Link('Click me', $url);
$link = $link->toRenderable();
$link['#attributes'] = [
  'class' => ['nm-share', 'nm-share-' . $type_name],
  'target' => ...
Score: 0
How do I programmatically alter the links displayed in the main navigation menu?
id flag

The main navigation menu in the site I am currently working on has a lot of menus. I want to hide the disabled ones.

I figured out that it is rendered via the menu_edit_form form.

entity.menu.edit_form:
  path: '/admin/structure/menu/manage/{menu}'
  defaults:
    _entity_form: 'menu.edit'
    _title_callback: '\Drupal\menu_ui\Controller\MenuController::menuTitle'
  requirements:
    _entity_access: 'me ...
Score: 0
liquidcms avatar
Custom taxes and fees
us flag

My client is looking for custom fees/taxes plugins that do the following:

The fees/taxes are state dependent (US only) and have "complex" rules that differ from state to state:

  • are taxes on top of fees (differ by state)
  • fees have a min/max amount (differ by state)
  • multiple taxes (4), some are percentage, some are combination of percentage/flat amount (differ by state).

There is no documentation on Com ...

Score: 1
Refresh a form with Ajax after closing a Dialog
mx flag
JFK

So I have a custom form in which I display a list of entities. Below that list, I added an “Add More” link which opens a Dialog. When I close (or submit) the Dialog, I want the list of entities to be updated dynamically without refresh.

enter image description here

I looked but I can't find a way to add a Dialog callback function. So I added an "update" button in my custom form with an ajax callback to refresh the form. Then, in ...

Score: 0
Migrate a two-textfield field
cn flag

I'm looking to migrate a text field from Drupal 6 to Drupal 9. The field has two text fields.

The table description returned by describe content_field_telfono ; is the following.

Field Type Null Key Default Extra
vid int(10) unsigned NO PRI 0
nid int(10) unsigned NO MUL 0
field_telfono_value varchar(10) YES NULL
delta int(10) unsigned NO PRI 0

The table content returned by

Score: 0
How to load the previous revision of a paragraph?
cn flag

I can load paragraphes of a nodes field using

$paragraphs = $node->get('my_field')->referencedEntities()

In hook_node_update I could load the previous paragraphes using

$paragraphs = $node->original->get('my_field')->referencedEntities()

But instead I would like to load the previews paragraph from their id, somethings like:

$paragraphs = $node->get('my_field')->referencedEn ...
Score: 0
How do I apply the `loading="lazy"` attribute to responsive media?
cn flag

On my Drupal 9 installation when I create an "image" field, Drupal automatically adds the loading="lazy" attribute.

When I create a "media" field with an "Adaptive Image Styles" display, the loading="lazy" attribute is not applied.

How to apply the loading="lazy" attribute to responsive media?

If I go to a media image, there is "lazy" :

enter image description here

If I go to a media image with the adaptive image style, there is no  ...

Score: 0
Simple OAuth + GraphQL authentication
bz flag

I'm trying to set up a decoupled Drupal architecture with the GraphQL module and Gatsby static site builder. Following online guides for this setup, I also installed/configured Simple OAuth for graphql consumer authorization. But no matter how I configure/reconfigure/install/uninstall, I consistently receive a "410 Unauthorized" message when attempting a simple GET request to the graphql API with the as ...

Score: 0
How to fix "Entity/Field Definitions" issue?
cn flag

In Drupal 9 I deleted an image field with the machine name field_poi_image and I have a media field with the same machine name. Since then there is an error message in the dashboard.

How can I correct this?

Entity/Field Definitions Definition of entities and/or fields do not match The following changes have been detected in entity type and field definitions. Contents The node.field_poi_image field needs ...

Score: 0
Add an event listener to select list
cn flag

I've attached the following js to an exposed views form field and it works on first page load but when the form is changed (by ajax) it doesn't fire.

I can't quite work out where to add an event listener for onchange of the select list.

The following doesn't use jQuery but uses the core once library so I would like to avoid jQuery.

/**
 * @file
 * Landing page adjustments.
 */

 (function (Drupal, once)  ...

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.