We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [8]

Version tag to tag issues specifically related to Drupal 8.x. Please note that version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

3,848 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
2answers
3k views

What is the equivalent of hook_translated_menu_link_alter() to Alter a menu link?

I want to alter the menu link in Drupal 8. In Drupal 7 we can achieve this using hook_translated_menu_link_alter function module_translated_menu_link_alter(&$item, $map) { global $user; if (!...
8
votes
1answer
737 views

With search_api_solr, how can I apply an significant field based boost when using solr 6.x?

I am using the solr backend for search_api on a drupal 8 site. I have added the value of a taxonomy term reference field (field_promoted_search) to the index. If an item of content has ...
7
votes
1answer
1k views

How do I enable and use a view mode for a product type?

In default commerce2 (drupal 8) I want to add second product-type view mode, to show in views - like teaser version, including add-to-cart btn with variations. I have additional field in Product type ...
7
votes
0answers
1k views

How do I translate theme settings?

How do you translate custom theme settings in Drupal 8? I use hook_form_system_theme_settings_alter to add custom settings to a theme. One setting is the text string (e.g. 'Menu') to display beside ...
6
votes
0answers
827 views

Custom view sorting plugin / handler

I am trying to create a custom sorting option for view that will sort result on the basis of percentage of 2 fields. field 1 = node__field_funding_amount field 2 = node__field_funding_goal and i am ...
6
votes
2answers
375 views

Big pipe and behaviors context

I have problem with drupal behaviors and context in combination with big pipe. It seems like context variable sometimes contains same part of page. I have tried: (function ($, Drupal) { Drupal....
6
votes
1answer
237 views

Is it possible to migrate data into multiple translations of entities?

I'm running a multilingual migration of events (which are stored as nodes) that have keywords on them where there are keywords (stored as terms). The keywords should be stored in a multilingual tags ...
6
votes
2answers
3k views

How to set required POST parameters for routes

With GET method we can do something like this example.user path: 'example/{user}' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' requirements: ...
5
votes
0answers
214 views

How to use Context with Views' Contextual Filters

I have content type City. I have a view page with contextual filters to show the cities at the URL pattern locations/<city id>. I want to use Context to add blocks to these cities pages but I ...
5
votes
2answers
305 views

Managing custom aliases on translated content

We have a Drupal 8 site with translated content, and using the Pathauto module. The issue we are running into is that when we un-check the "Generate automatic URL alias" on, say, the Chinese node, ...
5
votes
0answers
465 views

How do I make an archived-dump of my site?

I have multiple versions of drush and cannot make an archive-dump of my site. drush8 ard/drush8 archive-dump returns [error] The drush command 'ard' (and/or 'archive-dump') could not be found. ...
5
votes
1answer
743 views

Change views exposed filter format

I am build a JSON export using a View in Drupal 8. Problem is that the parameters for retrieving the json doesn't seem to work as I would want. In my View I need use two exposed filter criteria to ...
5
votes
1answer
2k views

Creating date field with only month and year

We are using the form API in a custom module (and not an entity field), how can we easily set the date widget for just year and month data entry. I've tried adding a #date_format attribute but no ...
5
votes
1answer
856 views

When I POST an image file via rest, response is 201: Object Moved, status is temporary

I'm attempting to POST images to Drupal 8 via the REST api. The creation is successful (201) and the images appear in the files list. However, there are problems. I'm not sure if they are ...
5
votes
3answers
2k views

How do I define a computed field equal to the concatenation of two fields of my custom entity?

I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, userID, created, changed. I created it with baseFieldDefinitions. I want to have a computed field ...
5
votes
1answer
7k views

How to create a “read more” button using AJAX in a module?

I'm working on a really simple module in Drupal 8 to get the hang of things. What it does (or rather, what the page I'm asking about in this question does) is grab some data of a bunch of simple ...
5
votes
1answer
144 views

Update core keeping other composer packages

After upgrading Drupal to the last version with Drush (8.1.15) the other composer.json dependencies (e.g. drupalconsole) are removed. Are there any way to update Drupal with Drush keeping other ...
5
votes
1answer
3k views

Clear only CSS/JavaScript cache when files are aggregated

When aggregating CSS/JavaScript files using performance page in Drupal 8, drush cc css-js doesn't work, and I've to clear/rebuild all cache. Is this a bug or the normal behavior? How do I properly ...
4
votes
0answers
519 views

Custom views filter for custom view field

I want to created a custom views field, following this tutorial: https://www.webomelette.com/creating-custom-views-field-drupal-8. This custom field counts and returns the number of referencing ...
4
votes
0answers
216 views

What is the way to restrict access to a store and its products by user?

I'm using Commerce 2 and I have: User A and User B Store X assigned to User A (by entity reference) Store Y assigned to User B I would like to restrict access to products of stores so that User A ...
4
votes
0answers
303 views

Image styles are not generated in Docker for Windows

When I open in browser http://localhost:1567/sites/default/files/styles/thumbnail/public/2017-10/478069720_1384178114_4.jpg, I see 404. The "original" images are uploaded successfully, and the ...
4
votes
1answer
2k views

EntityQuery with a condition on an array

I try to list all fields where a paragraph type is referenced (to find all contents which have paragraphs of a specific type). My problem: I do a EntityQuery on field_config entity type to find the ...
4
votes
0answers
2k views

How to setup Swift Mailer to send mails using SMTP server and TLS encryption?

I'm trying to send Drupal 8 emails using Swift Mailer (5.4.8, 8.x-1.0-beta1) and a remote SMTP server. The transport should be encrypted, so TLS should be used. This is my setting: Unfortunatly when ...
4
votes
0answers
805 views

How do I theme a modal popup?

How can I style Drupal 8 modal window to achieve Instagram style and behaviour? I'm creating modal through extending ControllerBase class, thus have full control of content. However I can't figure it ...
4
votes
0answers
1k views

Add Expression for Entity Query

I've been working with the entityQuery to query the db and get an array of filtered nids however I need to add an expression to my query. I've checked the Query class and found a protected sqlQuery ...
4
votes
1answer
81 views

Benefit of config entities over regular config entries?

In Drupal 8 it is possible to store configuration in "config entities". However, the same can also be achieved with non-entity config entries. E.g. one example for a config entity schema, from core....
4
votes
0answers
336 views

Front page without language prefix

I have a multilingual site on Drupal 8 migrated from Drupal 7. It has URL language detection method. Default language is English, it has path prefix /en. With this configuration front page is ...
4
votes
1answer
758 views

How to to render a webform (or any configurable form) in a node edit form?

I have a weird use case, where I was looking to perform the following: In a node edit form, allow a user to entity reference a collection of webforms When a user selects an appropriate webform from ...
4
votes
2answers
384 views

Detect when 'Remove' is clicked on a file widget form element?

I have a handful of file fields that have the following default Drupal behavior: User can upload a file User can upload another file in place User can remove file Standard config. Whats happening is ...
4
votes
1answer
571 views

Providing menu route parameter values from url

Suppose I have the following route in my ej.routing.yml file: ej.form.user.profile: path: '/user/{user}/ej_profile' defaults: _title: 'EJ Profile' _form: '\Drupal\ej\Form\User\ProfileForm' ...
4
votes
1answer
1k views

Adding elements to a field widget

What I need to accomplish is adding a link to a node to field widgets (the node contains the formatted instructions to properly compile the field). The goal is something like this: "What is this?" is ...
4
votes
1answer
3k views

“message”: “X-CSRF-Token request header is missing”

When using postman to fire post request I get this message. Does anyone has idea how to disable it? In this case it is post to register user so no authentification is required.
4
votes
1answer
1k views

Configuration changes that will not import?

I have some configuration that will not import. If I run drush config-import --preview I see the changes to be imported; I hit 'y' to import. When I run the same command, the changes are still there? ...
4
votes
1answer
650 views

How do I remove JOIN in hook_views_query_alter()?

I have a view with two filters (A + B). Filter B should only be included in the query, if a specific value in filter A is set (like a "conditional filter"). So I tried to remove the where condition ...
4
votes
1answer
1k views

Ajax pager with form callback

I created a form using the form api that outputs a list of results via an ajax callback. I want the said view to paginated. How can i do that? I'm using drupal 8 and don't want to use embeded views.
4
votes
2answers
781 views

Send mail notification when node of given type gets created

Use case: a small site where I want to warn all users by mail whenever a new content of a particular type is created. I thought I would try Rules+Actions to handle this. I'm working on a vanilla ...
4
votes
0answers
959 views

How to create a Draft view with Content Moderation?

In Drupal 7 with Workbench Moderation is easy to create a view to show the last Draft of a content: You have a relation in the view named Workbench Moderation: Node, so using the filter Workbench ...
4
votes
1answer
82 views

Why is my functional test not matching my manual testing?

I have a Drupal 8 module for banning users based on country. In it, I have the following test. public function setUp() { parent::setUp(); $this->drupalLogin($this->adminSitesUser); } ...
4
votes
1answer
611 views

Action links available options / caching

I have some action links defined in module.links.actions.yml which uses a custom "create entity" route. For entity creation I set up some restrictions and at some point the access is denied. The ...
4
votes
0answers
532 views

CAS Server setup

I have setup a Drupal 8 with CAS configurations - https://dev.cas.local Here is the configuration: Version: 2.0 or higher Hostname dev.cas.local Port 443 URI /cas SSL Verification Verify using web ...
4
votes
1answer
580 views

How to fix “Unable to save a field collection item without a valid reference to a host entity” error?

I programmatically created a series of custom content entities which contain field collections. My site had an execution timeout error in the middle of entity creation and saving. I can not delete ...
4
votes
1answer
1k views

How do I send user credentials and get the access token?

I am linking a Drupal site to an Android application. With the help of the Simple OAuth module, users will log in to my android app using their Drupal site credentials. I understand that once the ...
4
votes
0answers
65 views

Why are English translations of Field Labels shown on site's default language?

I have 5 languages and all my fields are translated into them. My default language is ancient Aryan. When I clear cache English translations of Fields Labels are displaying in default language. Other ...
4
votes
0answers
1k views

Loading a form in dialog/modal returns an error

I have a form with a submit button binded to an AJAX callback that opens up a modal with another AJAX form. The modal dialog opens with the form, but the AJAX submit in that modal form isn't ...
4
votes
0answers
111 views

drupal_process_states function doesn't work for managed_file

The following code is working for text field, but it's not working for image field. function THEMENAME_form_system_theme_settings_alter(&$form, FormStateInterface &$form_state, $form_id = ...
4
votes
0answers
731 views

Image upload AJAX error

I have an image field called field_image in a content type called Blog Post. I am able to use this field as expected, to upload and replace images, etc. I have a second content type called Event, ...
4
votes
0answers
854 views

Trying to set a twig global variable for a function

I have a Twig function in my theme that sets a random ID. The function works well if I include the entire function within any given template and then render the variable for that {{ randomID }} in the ...
4
votes
0answers
171 views

How to remove form validation in D8 under certain conditions?

I'm trying to save a node as a draft, but only if we are saving as a draft (Workbench Moderation). Otherwise, validation should be run as normal. The user must be allowed to save a node in any state,...
4
votes
0answers
852 views

Why is my field definition update not working?

My module extends the existing image field type by 2 new fields, copyright and description. FieldType plugin: <?php namespace Drupal\image_extra_fields\Plugin\Field\FieldType; use Drupal\...
4
votes
0answers
325 views

Execute form custom validator first before default validation

I have added a custom form validation on node/add page in drupal 8. The purpose of adding this validator is to add a slash before the path alias string. By default if a path alias string is added ...