Questions tagged [9]

Version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

Filter by
Sorted by
Tagged with
13 votes
3 answers
2k views

Require v8 only contrib module with v9 patch

Given I have Drupal 9 composer installation with composer-patches plugin and given a contrib module with a stable v8 release, but no v9 release (not even dev branch) and given that contrib module has ...
  • 5,122
3 votes
1 answer
541 views

How to properly manage field types for a content type created by a module?

I'm a bit confused about two different errors I get, which seem to contradict each other. I guess I didn't register my field types properly. The first one appears when I try to uninstall my module. ...
7 votes
2 answers
5k views

How can I verify users the first time they log in?

I was reading this article. I would like to know how logging in with the REST API in Drupal 8 works. By default, when users log in, Drupal will verify username and password. After the login, the ...
  • 747
3 votes
1 answer
686 views

Reverse entity reference lookup

I have a data structure where content type research has an entity reference field scientists. The content type scientists does not have any research reference entity field though. I can get all ...
  • 263
10 votes
2 answers
1k views

Use custom content entity theme suggestions in own module?

I have a custom content entity called 'offer'. I've added template_preprocess_offer() and offer_theme() to the offer.module file. function offer_theme($existing, $type, $theme, $path) { return [ ...
4 votes
1 answer
1k views

How can I use core's WebP support instead of the WebP module?

According to the change record, Drupal 9.2 supports WebP for better image compression. I've been using the WebP module on my 9.1 site to serve WebP images, but it has a performance-killing bug and I ...
3 votes
1 answer
404 views

How to properly log custom exceptions?

I'm trying to improve the code quality of my custom module by adding custom exceptions. Before, I was lazy and throwing \Exception everywhere, but I recently refactored all my code to use custom ...
0 votes
4 answers
1k views

I've just installed drush and am getting this error. What to do?

So I've just installed drush 11.2.0 with Drupal 9.4.6 and the first time I executed drush si, I got PHP Fatal error: Declaration of Drush\Application::setLogger(Psr\Log\LoggerInterface $logger) must ...
  • 568
-3 votes
1 answer
194 views

How can I programmatically add users? [closed]

How can I programmatically add users to an organic group?
  • 3
8 votes
2 answers
14k views

EntityQuery condition "is not equal to..."

Problem : I need filtering entities based on the value of a multiple-choice field. I want my query returns all entities except those who have a given value ('doe' for this example). Actual : multiple-...
7 votes
1 answer
395 views

What method should I use instead of Drupal\Core\Entity\Query\Sql\Query::addExpression()?

I am using Entity Query to select nodes of two different types. The fetching seems to be working, but I want to sort the returned values. Both the content types have different date fields. I know I ...
  • 121
5 votes
1 answer
1k views

What should be used instead of raw filter?

Drupal 9 theming documentation indicates that the Twig raw filter is deprecated in favor of verbatim. The ds-field-expert.html.twig template uses raw to render the input in the prefix and suffix field,...
  • 470
5 votes
3 answers
866 views

How can I restrict external URLs in link field to allow only certain domains?

After creating a Link field and use the Link with service icon format, I find out that there is no option to restrict external URLs to external domains that I want For example, if I only want to allow ...
  • 75
3 votes
1 answer
682 views

Disable caching for a front page path processor

I’m working on a project where users can create a book (core functionality). In a simple text field they can connect a domain to this book. This way the book is only accessible via this domain. For ...
  • 1,058
3 votes
2 answers
450 views

How to not show the "has been created" message? [duplicate]

I want to remove the message that is output in the message area when a new node is created. A typical message may look like this. "Article My article has been created." I examine the node ...
3 votes
1 answer
76 views

How to get Automation testing results of Drupal contributed module through Drupal.org rest API?

I am trying to get automated testing results of contributed modules through https://www.drupal.org/drupalorg/docs/apis/rest-and-other-apis. I am able to get nid and vid of any contributed module ...
2 votes
1 answer
227 views

Why hook_ENTITY_TYPE_access and hook_ENTITY_TYPE_create_access are not fired?

I'm implementing for nodes hook_ENTITY_TYPE_access() and hook_ENTITY_TYPE_create_access() for a project and they are not fired even after cleaning the cache many times. I checked the code and there is ...
2 votes
1 answer
665 views

How do I add fields to an existing custom entity? [closed]

I have a custom entity that fieldable. I need to add a field to it, and I want to do it through the UI. The entity was created in a custom module, which I can modify. How can I make the entity ...
2 votes
1 answer
3k views

drupal9 dev mode local settings : non existing cache.backend.null

In drupal9 my drupal8 local.settings.php conf generate an error when i empty cache Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have [error] requested a non-...
  • 3,111
2 votes
1 answer
732 views

How can I turn off the caching for a Paragraph type?

I'm rendering an array whose URL is dependent on a $_GET variable. Where the variable is present and valid, I want to serve an iframe with the _GET variable as part of the URL. At the moment the cache ...
2 votes
1 answer
1k views

Trouble with the upgrade of core 8.9 to 9.2

We are in the process of migrating to Drupal 9, and I am having nothing but problems with composer and trying to get Drupal core updated. I have provided my composer.json file, and a HUGE list of ...
  • 171
2 votes
1 answer
1k views

How can I manually upgrade my site?

I have updated my core to 8.9.0, all modules are Drupal 9 compatible and now I want to upgrade to Drupal 9.0.0. I always did my updates completely manually via FTP/web (swap core/vendor/root files, no ...
  • 158
1 vote
1 answer
443 views

How can I fix "Allowed memory size exhausted" on batch finish?

The batch processed all the items, but instead of showing the finish message, I see the error "Allowed memory size of 536870912 bytes exhausted". When I debug the code, I notice that Drupal ...
1 vote
1 answer
197 views

Migrate CSV to content type with paragraphs

I'm trying to import a CSV File into Content Types and Paragraphs, using Migrate module (and mainly this tutorial : https://mtech-llc.com/blog/charlotte-leon/migration-csv-data-paragraphs). For this I ...
1 vote
3 answers
93 views

ConstraintValidator fails to validate constraint on Taxonomy Term reference field

Client has a simple and consistent hierarchical taxonomy. Cities at the top level and Schools at the second level. . ├── City1 │   ├── School1 │   ├── School2 │   └── School5 └── City2 ├── School3 ...
  • 2,052
1 vote
2 answers
105 views

How can I control node access based on entity reference to multiple users

I have multiple uses for this functionality now but mainly for a private message system. What I want to do: Configure a content type with an entity reference to users Create nodes of that type and ...
  • 183
1 vote
1 answer
12k views

How do I fix an uncaught TypeError? [closed]

I am using Drupal 8.1.8. It is giving me many JavaScript errors. Uncaught TypeError: Cannot read property 'permissionsHash' of undefined Uncaught TypeError: Cannot set property 'StateModel' of ...
1 vote
1 answer
983 views

"Fatal error: Call to a member function setFormClass()"

I am trying to load the node in an external script, and shows me the following error. Fatal error: Call to a member function setFormClass() in field_ui_entity_type_build() The code causing the error ...
1 vote
0 answers
30 views

How do I use a hook to modify CiviCRM payment processor details in Webform?

I am trying to use hook_form_alter() to change the details of the CiviCRM Payment Processor for specific users (to change from live mode to test mode). On Drupal 7 it's in $form['submitted'] when Page ...
0 votes
0 answers
63 views

How do I display the already uploaded images in a custom form?

I build a custom form to edit nodes, which have a multiple files field I show using the following code. $files = $event->field_bijlages; $fileIds = []; foreach($files as $file) { $fileIds[] = $...
0 votes
1 answer
266 views

Show a summary calculated from webform submitted values on the submission preview page only (not on form) and re-use in e-mail handler

We need to display a computed summary of submitted information on both the submission preview page and in e-mails that are sent out. I'd expect this is a common usecase and wanted to check if i'm ...
  • 1,352
0 votes
0 answers
113 views

Custom block JavaScript not loading for anonymous users

I've created a custom block (via Drupal admin) that uses Twitter's API to insert tweets into a page. The necessary JavaScript loads for authenticated users but not anonymous users. I configured the JS ...
0 votes
1 answer
52 views

Implement node access checks for a node when content moderation is in use

I want to hook into hook_node_access and if the action is update or delete on a particular node type, I want to check the current user and the current node and see if they share field values. If they ...
  • 27.2k
0 votes
1 answer
73 views

Redirection from user login to another page for logged in users

Due to requirements with our reverse proxies, I had to show the user login form on a different URL. Well, no problem, I thought, I'll just copy the relevant section from user.routing.yml and display ...
0 votes
1 answer
206 views

How to remove or hide the Subject field for comments?

I have added a comment field to a content type. It is of the default comment type. I don't want my commenters to fill in a subject, rather, just a comment body. Trying to remove the Subject field, I ...
0 votes
0 answers
24 views

How to add code that will run on visiting a URL, in addition to another module that also has code that will run on same URL, & control execution order

I'd like to make a custom module that runs code when a URL is visited and then allows an existing module with code that also runs on same URL. So in the case of the existing module that runs on the ...
0 votes
0 answers
143 views

How can I list the nodes for which a Boolean value is FALSE or NULL?

On Drupal 9 I have a content type (Article), which has a not required Boolean field, Need Further Review. Its values are TRUE, FALSE, and NULL, where the latter is used when the node doesn't have yet ...
0 votes
1 answer
652 views

Symfony Routing Error

My site has completely gone blank after updating modules with Composer. This is the error I get. I've found some similar errors in a topic from the past, but they are all about earlier version of php ...
0 votes
1 answer
49 views

Render two taxonomy fields in one alphabetical list

I have two term reference fields: colours and tags. I have a poppy, it has tags: pretty and colours: red, green. I want html like: This flower is: green, pretty, red i.e. I want to take the terms ...
  • 3,969
0 votes
1 answer
162 views

How should I use hook_cache_flush() or hook_rebuild() in a custom module to execute JavaScript code when the cache is cleared?

I'm trying to create a module that executes some JavaScript code when the cache is flushed (via administrator menu or otherwise). I believe I can implement either hook_cache_flush() or hook_rebuild(), ...
  • 13
0 votes
1 answer
372 views

Site stuck in 'headers have already been sent' login loop after D9 upgrade

Suggestions for debugging a site which is now stuck in a "headers have already been sent" loop after successful login (redirect back to login form)? This is a production server for a site ...
0 votes
1 answer
862 views

How do I fix a var-dumper conflict?

My upgrade is failing. I am at 8.9.19 and I used upgrade-status to make sure all my modules are compatible with next major core version. I am following instructions at https://www.drupal.org/docs/...
  • 429
0 votes
1 answer
266 views

How do I migrate body content with [embed]*[/embed] tags?

Currently I am working on migrating a Drupal 7 site to Drupal 9. The nodes in the site has nodes with content similar to the following one. <h3><strong>WHAT WILL YOUR NEXT MEAL BE?</...
0 votes
1 answer
356 views

programmatically get child nodes referencing parent by entity reference uuid, using loadByProperties & entityTypeManager or other way without views

I tried this answer: https://drupal.stackexchange.com/a/298084/1082 But I can't seem to use 'field_scientists' => $entity_reference_uuid where, in my case, field_scientists is a field of type ...
0 votes
1 answer
291 views

Programmatic webform redirect on submission not redirecting

I have a webform with the confirmation set to redirect to URL (redirects to a custom path or URL) In my webform handler, I have the following: public function confirmForm(array &$form, ...
0 votes
1 answer
140 views

Add a link to a tableselect row

I'm interested in adding a link in a tableselect form row. Utilizing the #options key I can only add columns with strings. I am able to add form elements in the #options array similar to the #rows ...
0 votes
1 answer
670 views

FieldItemList::getValue always returns a string, even for a Boolean field

Supposed I added a custom Boolean field, whose cardinality is 1, to a content type. I create a node of that content type, enter a value for that field (for example, TRUE), and save the node. When I ...
0 votes
0 answers
78 views

How do you add a filter with manage form display?

So I know with form display, you add fields to the content type which then can be re-arranged under form display. But what about more complicated features, like filtering via taxonomy terms? I know ...
  • 387
0 votes
1 answer
337 views

phpwkhtmltopdf engine pdf printing configuration issues

The screenshot below shows my Entity Print configurations for created styled PDFs from node content. As shown in the screenshot I am using the phpwkhtmltopdf engine and the mikehaertl/phpwkhtmltopdf ...
  • 1,730
0 votes
1 answer
148 views

Hide path on frontpage redirect

In a custom module i'm using an EventSubscriber to redirect different people to different frontpages. Below is the simplified code I'm using. //GET PATH $nid = 1; $domain_url = \Drupal::service('...
  • 1,058