Questions tagged [8]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Trying to sort a views result by a global views conditional field

I'm attempting to use hook_views_pre_render in a Drupal 8.9.20 site to sort the results of a view by a global views conditional field and I could really use some help. I've spent some hours searching ...
  • 1
0 votes
2 answers
45 views

How to check if webform has a draft submission?

I'm using hook_webform_submission_form_alter() to prepopulate some form values. When a user saves a draft of their webform submission and comes back to it later, the code in ...
  • 280
0 votes
1 answer
33 views

How to check for content type in hook_form_alter

I see from the api and various posts that I can identify a specific form to change using hook_form_alter, like this: hook_form_FORM_ID_alter() From experience, I know this can be done in the .theme ...
  • 193
1 vote
1 answer
12 views

List of fields to put on a REST call

I have a rest resource configured from Rest UI page (let's say /entity/user: POST); I would like to share the endpoint with others devs so they can call the API (create users for e.g.). Where to get ...
  • 43
0 votes
1 answer
38 views

Run custom php code or file in drupal content type form submission

I have this drupal site, there is a candidate registration page where anyone can fill the details (name, gender, address, mobile no etc) and submits and a success node page is displayed with all ...
0 votes
0 answers
24 views

How do I link to a Views Page from a systemAdminMenuBlockPage page?

I have a custom module that I have a systemAdminMenuBlockPage in that I'd like to link to various content administration Views pages from. I basically have a custom Configuration menu item doing this ...
0 votes
1 answer
43 views

ReCaptcha doesn't show on Simplenews Subscription Block

I have the subscription form of Simplenews in the footer, which should be protected with reCaptcha. I installed reCaptcha and created a captcha point with the form ID of the Simplenews block. ...
0 votes
1 answer
46 views

How can I add a button to every row of custom column?

I have created a custom column in the content listing section using hook_views_data(). I want to add a button to the every row of that custom column. Can anyone help me with this issue? function ...
0 votes
0 answers
22 views

Views: How to filter content by taxonomy terms that are not selected?

I have a view of a specific content type that can be filtered by two different taxonomies A and B. Some nodes that have the taxonomy term A1 also have the term B5. Now when I filter only by the term ...
0 votes
1 answer
77 views

How to use a Controller method inside a service with dependency injection?

I'm using the diff module for a project, this module has a method inside a Controller that I want to use in a service to reuse code. As this time I'm just calling the method like ...
0 votes
0 answers
38 views

How to import config to a site installed with a profile?

Good day. I’ve installed a profile, made my settings, entered my content, exported config and pushed everything to the repo. Now, when I clone it somewhere else and attempt to install using the config,...
  • 568
2 votes
0 answers
70 views

Why doesn't the entity access handler I wrote work when the entity is referenced?

I have set a handler for the access of my entity but when I reference it in another entity, the access is not checked. I want the reference and the entity to have the same access check. Any idea ? The ...
  • 21
0 votes
1 answer
68 views

AliasManagerInterface -deprecated Drupal\Core\Path\AliasManagerInterface

Error: The website encountered an unexpected error. Please try again later. TypeError: Argument passed to Drupal{module name}\Theme{class name}::__construct() must implement interface Drupal\...
  • 1
0 votes
0 answers
495 views

Argument 2 passed to Symfony\Component\Routing\RouteCollection::add() must be an instance of Symfony\Component\Routing\Route, boolean given

Ubuntu 18.04.6 Apache2, Postgresql 10, Drupal 8.9.6, PHP 7.2.34 (most of the modules require these versions) I've tried trouble shooting this problem for multiple weeks. I'm attempting to migrate a ...
-1 votes
2 answers
315 views

How to get Webform Element value into Custom Token

How to assign a value of Webform Element (IP_ADDRESS) to a Custom Token ? The Step that I did: use Drupal\webform\WebformSubmissionInterface; function MODULE_token_info() { // token info } function ...
  • 130
0 votes
0 answers
49 views

How to determine entity where image field is housed?

I need to check if an image media field is housed in a paragraph to remove the alt attribute of that attribute. The same image field could be referenced anywhere. I could remove the alt field it ...
  • 858
0 votes
0 answers
325 views

PluginNotFoundException entity type does not exist when trying to uninstall any module

I've got this drupal website from a client that the another developer created, and they've made a mess with many things in this site. I'm having a problem where every time I try to uninstall a module, ...
0 votes
1 answer
71 views

How can I attach a newly added paragraph to existing records? [closed]

While editing a form, I needed to delete some fields and add a new paragraph. The issue here is, the newly added paragraph is not initialized in the edit form and that makes sense because the old data ...
0 votes
1 answer
75 views

How do I restrict content access programmatically?

Something is baffling me. I have this view of streams to users. An admin may make a stream to themselves, a specific person or everyone. I also have this code in which a non-admin user may see only ...
  • 568
0 votes
0 answers
63 views

how to get field image of a referenced entity in paragraph template

I made a paragraph with a referenced entity field to a content type called "tools" Actually I can get the title and body text like that : <h3>{{ content.field_tools_and_services.0['#...
1 vote
0 answers
44 views

Count how often a route is called

I have written a custom module that exports nodes in different formats. The module itself works great but now I would to count how often one of the custom routes is called. The desired route in the ...
  • 141
0 votes
1 answer
183 views

How to get menu Attributes from a theme's preprocess function?

I am developing a theme and trying to send custom vars to a twig menu template (since it pulls data from config) and have a loop to add variables in preprocess: foreach($attributes as $attribute => ...
  • 303
0 votes
0 answers
26 views

How do I show sets of questions based on the value of another field?

I am trying to create a registration webform based on the type of program students are registering for. For example if students have options to select ( School A, School B, School C, etc.) I would ...
0 votes
0 answers
13 views

How to apply Views bulk operations on nodes related with layout builder settings?

I have a number of nodes of a particular content type with Layout Builder enabled. Layout Builder has an option to revert to the default for each node of a content type. How can we expose this ...
  • 858
3 votes
0 answers
118 views

Field formatter with twig editor in settings form

I've created Drupal 9 module with custom field formatter for many field types (string, entity_reference, image etc). I'm trying to implement twig editor in the formatter to control output. I need to ...
0 votes
0 answers
34 views

What could cause these fields to be reverted to unsortable?

I've been working on this view for some time. I've 5 page and 5 block displays and have a table in each. I click the table settings, sort every field that needs to be sorted, then save the view, ...
  • 568
2 votes
1 answer
272 views

How can I make route parameters optional in a routing callback?

I needed to create a route in which the path of the route would be completely dynamic and so I created a routing callback. <?php namespace Drupal\uber_affiliate\Routing; use Symfony\Component\...
  • 858
0 votes
0 answers
16 views

How do I insert the corresponding text content from source into email based on selection?

I have run into a wall trying to find a solution to this problem and am hopeful someone here may have some feedback or ideas. (I'm on Drupal 8 btw) A department in my organization wants a form with a ...
0 votes
1 answer
52 views

Can a template file write, copy, or rename files? [closed]

Can code put in a template file write, copy, rename files, or read files that aren't template files?
1 vote
0 answers
198 views

How do I solve "RouteNotFoundException: Route "jsonapi.settings" does not exist" which occurs while installing the REST UI module? [closed]

When I am trying to install or uninstall a module the below error shows up. The same error is displayed when I go to webservices (Home > Admin > Configuration > Web Services). The website ...
0 votes
0 answers
43 views

How do I send a notification email as soon as file is uploaded from the node add/edit form?

I have a media video content type that has a video file field (takes a file), name, and air date. The video files are saved on amazon S3 not locally. I want to monitor the files that are uploaded and ...
  • 251
-2 votes
1 answer
369 views

How to pass and receive an http request body in GET?

I have two Drupal sites within one project. I want to send a GET request but I need to pass a lot of parameters. So instead of passing them in the query (which will lead to an extremely long URL), I ...
  • 41
0 votes
1 answer
38 views

How to use the user profile photo as the default image in a content type image field?

I would like to pull the current user profile photo in a content type image field but the default image option only allows the admin to choose an image file. Is there a module that allows the admin to ...
  • 859
0 votes
1 answer
184 views

How to get S3 file path from URI?

So inside my hook function I have URI of some file and I need to find it's S3 path (using s3fs module). How can I do that, to avoid manual string manipulation? Is there some helper function? I found ...
  • 485
0 votes
0 answers
101 views

Remove N/A option in radio button

I made a field in text list format with radio button widget and I want to remove the N/A option, but my field must be not required. I tried this code without success. function ...
  • 1
0 votes
1 answer
198 views

How to theme a pager with twig?

I've added a pager to a custom page rendered programmatically from a controller. I want to customize the pager. How can I do it without overriding the standard pager twig? This is the hook_theme: ...
0 votes
0 answers
20 views

Is there a way to nest links with the link field?

Working on a project where a sub menu uses the link field. Now they want a dropdown, but my drupal experience is extremely limited and google doesn't give me anything. I know you can with actual menus,...
  • 1
-2 votes
1 answer
167 views

How do I get a node by its ID?

Using {{ drupal_entity('node', '123', 'body') }} in a template file, I can get the node body and title. Is there a way to get all the available node properties?
1 vote
0 answers
42 views

Create a link to a cart to be used in emails

I would like to be able to create a link to an anonymous users cart, and send this to the user in an email. When the user clicks this link, he should be taken to his cart. (As part of an "...
1 vote
0 answers
102 views

Need help with Cache::invalidateTags() and cacheable metadata in REST route

I have a REST route that returns some JSON. I am trying to get cache tags working correct, but it doesn't seem to be working. Only updates if I flush all cache. I have a queue that runs on cron every ...
  • 437
0 votes
1 answer
95 views

How to have some element of a custom form rendered outside <form>

I have a form based on FormBase. All the form is wrapped by form.html.twig. I want to render $form['charts'] outside the <form>. I was able to do this, but {{ children }} still render all the ...
  • 672
1 vote
1 answer
305 views

AjaxCommand to scroll to top of page?

I have created an AJAX form. After the form is submitted, I call $this->createOkResponse() which updates a section of the page with a message (it replaces the form with the message). It all works ...
5 votes
2 answers
240 views

How can I run the inbuilt Drush 10.x commands as user #1?

I have a Drupal Queue worker class that fetches the Entity objects from Drupal to index to Elasticsearch. The following command is causing the lesser documents to show up in Elasticsearch since by ...
  • 2,476
0 votes
1 answer
26 views

How do I update the sort field value dynamicaly?

I have a requirement to list events via view, but these events are categorized as past, ongoing and upcoming events. View results should show ongoing first, then upcoming and past events in the same ...
  • 874
1 vote
1 answer
169 views

How do I translate a custom string in "Global: Custom text"?

In D9 website I have a view with Global: Custom text field. In that field I have placed a string like this: <span class="general-info">{{ 'General Info:'|t }}</span> I want to ...
0 votes
0 answers
62 views

How do I upgrade without upgrading contributed modules?

I am trying to do a core upgrade, but my dry-run shows Drupal wants to install a number of modules that are already installed. I run composer update "drupal/core-*" --with-all-dependencies --...
0 votes
0 answers
121 views

I cannot install a module

I have installed a Drupal 8.0.0 local test site in Windows 7 and I am trying to install Devel via Composer, running: composer require drupal/devel:^4.1. I get the following message in the command line:...
  • 49
0 votes
1 answer
54 views

Use translations with nl2br in template

Is it possible to use translations with nl2br? I tried {{ "This offer may \n interest you"|nl2br|t }}, but it doesn't translate the string because it contains a '\n' character. I already ...
0 votes
0 answers
20 views

Changes text on form alter [duplicate]

I want to changes the text new information to Latest information Below is object and contain protect string as [string:protected]. How I can i changes text. stdClass Object ( [__CLASS__] => Drupal\...
0 votes
2 answers
158 views

How to get newly created user id in user_presave hook?

Following is my .module file code /** * Implements hook_user_presave(). */ function cost_sheet_user_presave($account) { $source_userid = $account->id(); \Drupal::messenger()->...
  • 480

1
2 3 4 5
316