Skip to main content

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,535
3 votes
1 answer
871 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
  • 777
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
1k 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
4k 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
  • 610
1 vote
2 answers
426 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
  • 414
0 votes
1 answer
110 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
474 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
319 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
16k 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
5k 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,439
7 votes
1 answer
912 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
5 votes
1 answer
320 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
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
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
2 answers
933 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
3 votes
1 answer
989 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,378
3 votes
1 answer
99 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
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
474 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
1 answer
14k 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 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
387 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
2 answers
1k 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
  • 162
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
  • 190
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
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
918 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
1 answer
298 views

Cannot change layout of translated paragraph nodes

I make use of Paragraphs to build content nodes along with Drupal's translations to translate a node to a different language. Although the node can be translated, I am unable to move / reshuffle ...
mauzilla's user avatar
  • 173
1 vote
1 answer
339 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
3 answers
125 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,112
1 vote
2 answers
2k 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
1 answer
660 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
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
0 votes
2 answers
608 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 ...
sisko's user avatar
  • 1,730
0 votes
1 answer
237 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('...
Joost's user avatar
  • 1,378
0 votes
1 answer
151 views

How can I solve form "errors has been found" with custom Ajax dependant field and other Ajax fields?

I've altered a node\edit form where there are two taxonomy refence fields with a select widget. I've added a custom ajax callback on the first field, in order to populate the options of the second one ...
Giuseppe's user avatar
  • 981
0 votes
1 answer
458 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
161 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
182 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
198 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.9k
0 votes
0 answers
213 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
0 votes
1 answer
795 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, ...
JAyenGreen's user avatar
0 votes
1 answer
261 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(), ...
Joseph's user avatar
  • 13
0 votes
1 answer
128 views

Twig template for specific node view

I have a views-view--resources-filter.html.twig file. Within here I have a better exposed filters form and I loop through the resources (node) with the available {{ rows }} variable. My question is, ...
Jorn Reed's user avatar