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
14 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 ...
Hudri's user avatar
  • 5,473
3 votes
1 answer
785 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. ...
alex-schuster's user avatar
7 votes
2 answers
6k 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 ...
Jonh's user avatar
  • 767
3 votes
1 answer
1k 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 ...
supersize's user avatar
  • 263
12 votes
2 answers
2k 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 [ ...
Stef Van Looveren's user avatar
4 votes
1 answer
963 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 ...
Patrick Kenny's user avatar
2 votes
4 answers
3k 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 this error. PHP Fatal error: Declaration of Drush\Application::setLogger(Psr\Log\LoggerInterface $...
Kartagis's user avatar
  • 612
1 vote
2 answers
289 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 ...
aharown07's user avatar
  • 382
0 votes
1 answer
91 views

Is there any danger in uninstalling Redirect module?

Drupal 9.5.3 with no core customizations and very few contrib modules: Redirect Asset Injector Token All nodes in this website have alternative aliases such as example.com/my-first-node instead of ...
somo's user avatar
  • 5
-1 votes
1 answer
402 views

Programmatically add values in a select field: issues when submitting [duplicate]

I'm inserting some options in the #options element of the select render array: foreach ($files['files'] as $file) { $form['field_session_row']['widget'][0]['subform'][$field_name]['widget']['#...
maicol07's user avatar
  • 101
-3 votes
1 answer
300 views

How can I programmatically add users? [closed]

How can I programmatically add users to an organic group?
ankur's user avatar
  • 3
8 votes
2 answers
15k 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-...
Antoine Subit's user avatar
7 votes
1 answer
758 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 ...
Akansha's user avatar
  • 121
7 votes
1 answer
4k 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-...
Matoeil's user avatar
  • 3,389
5 votes
3 answers
1k 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 ...
MrIssue's user avatar
  • 75
5 votes
1 answer
291 views

Force a single value base field to be in a separate table?

I have a custom entity type (eg: myentitytype), and I would like to add a new base field to it via hook_entity_base_field_info(). As I understand it, single value fields (with a cardinality of 1) will ...
m.stenta's user avatar
  • 743
4 votes
1 answer
2k 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 ...
Patrick Kenny's user avatar
3 votes
1 answer
884 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 ...
Joost's user avatar
  • 1,318
3 votes
1 answer
96 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 ...
Vivank Sharma's user avatar
3 votes
2 answers
822 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 ...
Free Radical's user avatar
  • 15.1k
2 votes
1 answer
13k 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 ...
Md. Shafiq Hossain's user avatar
2 votes
1 answer
1k 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 ...
Phill upNorth's user avatar
2 votes
1 answer
1k 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 ...
joekrukosky's user avatar
2 votes
1 answer
3k views

How do I programmatically publish the latest revision?

My workflow is draft and publish. I create and publish a page. I create a draft of the page. There is now the published page, but the latest revision is the draft. How do I programmatically set as ...
esod's user avatar
  • 319
2 votes
1 answer
394 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 ...
Adrian Cid Almaguer's user avatar
2 votes
2 answers
856 views

How do you override a module's template from another module?

I'm trying to override an email template of the webform module. The project is headless so we don't have a custom theme, and we'd like to stick with the Adminimal contrib theme. However, we do have a ...
nstCactus's user avatar
  • 152
2 votes
1 answer
306 views

Why is MethodNotAllowedException thrown when an image is uploaded with CKEditor 5?

After updating Drupal to 9.5.3, I had this warning: Deprecated modules found: CKEditor. So I upgraded from CKEditor to CKEditor 5 following this documentation. After some setup on text formats, I made ...
Diatherm Condole's user avatar
2 votes
1 answer
2k 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 ...
Ex0r's user avatar
  • 181
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 ...
c1u31355's user avatar
  • 170
1 vote
3 answers
4k views

Authentication required (git.drupalcode.org)

On Drupal 9, I want to install the Taxonomy menu module using Composer, but I get the following error. Using version ^3.4 for drupal/taxonomy_menu ./composer.json has been updated Loading composer ...
Jean-Pierre Mena's user avatar
1 vote
1 answer
313 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 ...
CanardPpc's user avatar
1 vote
1 answer
792 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 ...
Egor Elkin's user avatar
1 vote
2 answers
962 views

Plugin not found

I am overwriting the CommentBulkForm class in my module. namespace Drupal\mymod\Plugin\views\field; use Drupal\comment\Plugin\views\field\CommentBulkForm; /** * Defines a custom comment operations ...
chaydru's user avatar
  • 43
1 vote
1 answer
1k 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/...
pglatz's user avatar
  • 469
1 vote
2 answers
2k 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 ...
Filip Breckx's user avatar
1 vote
1 answer
420 views

Problem with Adding new fields with Ajax call to a custom form

I have a simple form where I am trying to add a couple of fields to it when the user clicks a button using an ajax callback. Here is what I have: public function buildForm($form, FormStateInterface $...
Akbar Bakhshi's user avatar
1 vote
3 answers
117 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 ...
hotwebmatter's user avatar
  • 2,102
1 vote
1 answer
1k 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 ...
Tanvir Ahmad's user avatar
0 votes
1 answer
1k 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 ...
john Smith's user avatar
0 votes
1 answer
280 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 ...
spacecraft96's user avatar
0 votes
1 answer
67 views

Why can’t I install the module after uploading it?

I uploaded the Commerce Core module (8.x-2.32) from the /admin/modules/install tab. After uploading it, the modules list shows the module as disabled. I cannot select the checkbox shown for this ...
0 votes
1 answer
411 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 ...
al-hadi's user avatar
0 votes
0 answers
79 views

How can I programmatically set the options for a views exposed filter?

While it is possible to use hook_form_FORM_ID_alter() to programmatically set the options for any select input, with a views exposed filter there is the added complication of not knowing how Drupal ...
arnoldbird's user avatar
  • 1,173
0 votes
0 answers
157 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[] = $...
user108721's user avatar
0 votes
1 answer
122 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 ...
Francesco Marchetti-Stasi's user avatar
0 votes
1 answer
615 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 ...
William Turrell's user avatar
0 votes
1 answer
496 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?</...
miststudent2011's user avatar
0 votes
1 answer
64 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 ...
artfulrobot's user avatar
  • 4,009
0 votes
1 answer
146 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 ...
Kevin's user avatar
  • 27.8k
0 votes
0 answers
188 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 ...
Brian Zelip's user avatar