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
1 answer
363 views

Pre process a template that uses layout display

I want to preprocess a user account display. I want to manipulate a field value at display time. for example, i want to change: field_prefered_color: redto : field_prefered_color: red - Cool, that is ...
2 votes
2 answers
6k views

How to get checkboxes values in a form?

This is my code : $form['how_many'] = [ '#type' => 'checkboxes', '#required' => true, '#options' => [ '1' => t('one'), '2' => t('two'), '3' => t('three') ], ...
1 vote
1 answer
366 views

How can I add styles attribute to Global Custom field markup?

I have created a view to display my articles and I would like the article thumbnails to be used as background. So I added the different fields I've hidden. I added a relationship to the image field ...
0 votes
1 answer
1k views

Migration Source YML File import date string into date and time field of content type

I have a json file full of data exported from a wordpress site, one field being a string representing a date and time: "03/15/2012 14:46:19". I would like to import that string into a date and time ...
1 vote
1 answer
860 views

Create custom endpoints by extending the Resource Base class

I created a custom endpoints by extending the core of Drupal. but I can not retrieve JSON data. I do not know what value to put in 'note: serialization_class /** * Provides a resource to get bundles ...
0 votes
0 answers
13 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 ...
2 votes
2 answers
1k views

How can I apply different templates based on taxonomy hierarchy?

I'm new to Drupal and I don't have extensive knowledge so I'm hoping I can get this question answered. I want the taxonomy pages of lower hierarchy to be displayed differently from the higher by ...
2 votes
1 answer
3k views

How can I specify inner elements template in custom login page?

I am new in Drupal 8. I want to create a new theme to according to my HTML. What is the best practice to integrating a custom build theme to drupal engine. I have covered all sections in Drupal 8 ...
0 votes
1 answer
364 views

Views exposed filter by season from date field (date range group as month only?)

How would I create an exposed filter by season (spring, summer, fall, winter) based on date fields? I figured the approach would be to create date range filter groups by MONTH only (no year), but I ...
0 votes
0 answers
6 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 ...
0 votes
2 answers
1k views

Ajax error on node form edit page

I'm trying to ajaxify part of node form. I have a hook_form_alter that adds extra ajax property to a widget of select field. The problem I'm facing is the callback method / function, which is not ...
2 votes
2 answers
680 views

Reference View in Entity Reference field

I have a content type that has an entity reference field allowing you to link to other pages and add a custom image, for nice big CTAs. However, it's come to light that some of the links may need to ...
2 votes
1 answer
365 views

ANDs within OrConditionGroups

I'm trying to use entityQuery in Drupal 8 to perform an "and" within an "or" group. A simplified version of what I'm trying to do is this: Query for all apples, oranges and bananas ...
0 votes
1 answer
517 views

Migrate: Create term(s) if they do not yet exist

Question similar to this question here, but this time, I am not doing a separate migration later. I want to create taxonomy terms if they do not exist while processing a record. Does entity_lookup do ...
0 votes
1 answer
2k views

How do I check radio buttons in Twig template?

In a form, I have this field: $form['payment'] = [ '#type' => 'radios', '#title' => $this->t('Payment Mode'), '#options' => [ 'chk' => $this->t('by check'), 'tfr' =&...
2 votes
0 answers
56 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 ...
1 vote
2 answers
5k views

Pass variables from controller to existing node template file

In the Drupal 8 documentation I have found a way how to pass variable from controller to custom twig template https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-...
0 votes
1 answer
439 views

How to use HTML in a webform component's title?

We have a checkbox which's title should have HTML (<sup></sup>) but its rendered as text rather than HTML. How to use HTML in a webform component's title?
0 votes
2 answers
2k views

"User warning: The following theme is missing from the file system: media in drupal_get_filename()"

What does this error message mean? How can I fix it? User warning: The following theme is missing from the file system: media in drupal_get_filename() (line 268 of core/includes/bootstrap.inc). ...
0 votes
1 answer
363 views

How do I add a link to the #title property of a checkbox?

I created a custom module for Drupal 8.6, and I want to post a link to my terms and conditions. This is the code I am using. namespace Drupal\commerce_agree_cgv\Plugin\Commerce\CheckoutPane; use ...
0 votes
1 answer
670 views

Can't install modules from UI when site placed in subdirectory

I have Drupal 8 installed in a subfolder (www.example.com/drupal), and I have my root .htaccess configured to mask the subfolder (i.e. the URLs resolve to www.example.com; /drupal does not appear in ...
0 votes
1 answer
717 views

REST API Guzzle POST gives timeout but the same call works if I run it on the server cli

I have Drupal running in a docker container and nginx running in another container. When I do the login call through postman or directly on the webserver cli it works perfectly. But when I do call ...
1 vote
1 answer
522 views

Why is the login redirecting to the access denied page?

This question has been asked before but I see only D7 versions of the question, and none of their answers have helped me in D8. I log in perfectly fine with Chrome or Firefox, but IE 11 redirects to ...
18 votes
5 answers
27k views

How do I set up CORS?

Drupal 8 has RESTful web service in-built in core and since 8.2 we don't need cors module. Now to use services we just enable and configure default.service.yml file as specified in here However, I ...
0 votes
1 answer
615 views

Extend core modernizr library

I am noticing objectFit is not part of Drupal 8 core/modernizr library. How do I add objectFit detection without overriding core modernizr?
0 votes
2 answers
398 views

How do I add a region to the Color module?

I have a menu I would like to be able to style with the Color module. I have found many examples for the Drupal 7 Color module and they have led me to believe that if I just add a line to the 'fields'...
1 vote
2 answers
653 views

Why is my library not attached when programmatically rendering a block?

I have this block: public function build() { $build = [ '#attached' => [ 'library' => [ 'mymodule/mylibrary', ], ], '#markup' => '<!-- see template -->...
1 vote
1 answer
803 views

How do I programmatically translate a string?

I am working on one custom module to alter the fields labels of user login form for visitors. I created a module to alter the labels in the user login form. The French language is enabled on the setup....
0 votes
1 answer
734 views

Issues trying to understand and debug simplesamlphp error

Simplesamlphp used to work on the site. Something changed and now it does not. The IDP remote config has been verified, including the cert The SP cert and pem in the simplesamlphp/config folder have ...
5 votes
2 answers
1k views

Drush cim: error "Table xyz already exists"

I'm trying to deploy a dev website to a dev server. When running drush cim on the dev server, drush ends with an error message: Table honeypot_user already exists When running drush cim again ...
0 votes
1 answer
871 views

Send email to Commerce customer after order status is changed to Completed

I am attempting to develop a module that will send an email to a customer in my Commerce 2 store when that customer's order's status is updated to "Completed". I am basing my module off of ...
1 vote
2 answers
4k views

"Uncaught TypeError: Cannot read property 'getAttribute' of undefined"

There are some posts about this error for Drupal 7, but I'm using Drupal 8.1 and those solutions don't work for D8. I tried this patch (coded for D7) and doesn't work. The effect of the error is ...
0 votes
0 answers
32 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, ...
2 votes
1 answer
63 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\...
0 votes
1 answer
417 views

Symfony's getQueryString method doesn't return modified query parameters

Symfony's getQueryString method doesn't return modified query parameters. So how should someone go about getting a modified query parameter string? Example code: $request = \Drupal::request(); ...
11 votes
1 answer
355 views

Patch drupal.org project (core/module/theme) with issue fork

The new fork based merge request (MR) approach is pretty neat to get the patches created/reviewed/merged. However, if you are using the patch via cweagans/composer-patches, we have a few options. ...
1 vote
3 answers
1k views

The missing modules don't get installed after updating with Composer

To update a site locally, I cloned the code base with git to my local computer and imported the database, then ran "composer update --with-dependencies", there were no errors, then I went to /web ...
2 votes
1 answer
1k views

How do I integrate media (e.g. attaching audio) to nodes?

I installed the Media Entity module for Drupal 8. I thought it would somehow facilitate adding Mp3, etc, as Media does in Drupal 7, where I could specify a media player type for an audio file. (And ...
1 vote
2 answers
418 views

How to have a field displayed depending on user's role in Views?

I use Views module to display the content of a custom entity with Page view (not Block view). I'd like to have one field displayed only if the user has a certain role. What is the best way to do that?
-2 votes
0 answers
17 views

How can I send notifications to content editors to review content after a specific time interval?

I need to send content review email notification to content editors when a content is not updated for a specific duration. For example I have two content types, Article and Blog. If an article content ...
12 votes
6 answers
4k views

How to rerun hook_post_update_NAME()

Drupal 8 introduced hook_post_update_NAME() which has some benefits over hook_update_n, for updating modules. Each hook_post_update_NAME() should only run once, but sometimes I want to rerun it, like ...
0 votes
2 answers
254 views

Seven sub-theme shows branding and nav instead of local tasks / admin menu

My client wants some basic changes to the Drupal admin pages (yay!) so I'm trying to create a sub-theme of the core seven theme. I have my sub theme working and my css is being loaded, but the local ...
3 votes
1 answer
697 views

Can I have both Language and Country path prefixes?

On our site, paths are all prefixed by language and country. For example: http://example.com/en/us/about In Drupal 7, a previous vendor implemented this by using the Persistent URL module, which ...
0 votes
1 answer
5k views

How to sort by condition in entityQuery

I want to get a list that the items with a specific term in the top (like promote). The query would be like: $query = \Drupal::entityQuery('node') ->condition('status', 1) ->condition('type'...
0 votes
0 answers
13 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 ...
4 votes
1 answer
3k views

How to rename uploaded files

Using Drupal 8, I want to rename and clean all filenames, e.g. If someone uploads file named like this Screen Shot 2016-03-29 at 1.13.21 PM.jpg, I want to clean it so that convert all spaces to dashes ...
9 votes
3 answers
6k views

How do I verify a route exists?

In Drupal 8, I need to verify a route exists or not in a custom module. How can I achieve this?
3 votes
1 answer
2k views

How can I log variables to a txt file?

In Drupal 7 I use devel's drupal_debug() or its alias dd() to log a variable to a drupal_debug.txt in the site's temp directory. In the Drupal 8 version of devel this function has disappeared. It ...
0 votes
1 answer
679 views

Submission of dynamically generated input fields

I have created data entry form using Drupal 8 Webform (Yaml forms), Part of the form is table field which hosts dynamically generted textfields using jquery shown below: $(document).ready(function(){...
5 votes
3 answers
8k views

Default value of a 'managed file' field

I created an edit custom form (of a node) via a custom module. From this form, I have a "managed file" field (for one picture) and I set his default value to a fid; However, when my form is rendered, ...

1
2 3 4 5
317