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
0answers
31 views

How can I add a “target” attribute to a custom form?

I've made a custom form in a module in Drupal 8, but I'd like to add target="_blank" in the form tag. When I try to add it in $form['#attributes']['target'], the attribute is shown in the wrapper of ...
1
vote
1answer
37 views

How do I change the salt used for the user password when creating an account?

I am working on Drupal 8 site where the client has asked us to use their own custom salt when storing the user password in the database. Is it possible to set a custom salt for a Drupal site? The ...
0
votes
1answer
585 views

How do I get a list of all CSS and JS that are attached to a page?

In Drupal 8, how do I get all CSS and JS that is attached to a page? In Drupal 7, I could use drupal_add_css() or drupal_add_js() without arguments, to get an array containing a list of all the files/...
0
votes
0answers
20 views

Unable to auto-create node from webform

I attempted to create a custom module that automatically creates a node upon submission. I used the second response in this post: How to create a node out of a webform submission? Per the ...
0
votes
0answers
19 views

How to update default value of a datetime field?

I have a content type 'News' with a datetime field. I'm trying to alter its default value depending the choice of another field. So, i added some AJAX in the form : <?php /** * Implements ...
1
vote
0answers
15 views

Use default language domain when editing translated content

I have a multi-lingual site setup that uses two domains: example.com (Primary/Default English domain) example.mx (Spanish translation) When editing translated content the user is forced to 'example....
0
votes
1answer
1k views

Trusted Host Patterns Settings Not working with IP

So I am trying to get this drupal(drupal845.localhost) site accessible by my VM. But the Trusted Host Settings are not working. Here are the settings in my settings.php $settings['...
0
votes
1answer
25 views

How can I have multiple content types pick up the same template?

I want to override the template for 5 content type that they have all the same attributes, but a different name ,so the suggestion is : node--contenttype1.html.twig node--contenttype2.html.twig ...
0
votes
1answer
23 views

drupal 8 modifying the menu items path

I work on an drupal 8 application that use the group module with the restriction of only one group per user. i want to be able to modify the menu items so that the id of the user's group is always in ...
0
votes
0answers
18 views

How can I disable the default form validation error message?

I am using Drupal 8. When using "webform" module with the "inline form error" module, it shows both the validation error summary above form and each field error under the field. How to disable the ...
4
votes
3answers
633 views

Debug arrays from hook_cron?

Does anybody know of the proper way to debug objects from within hook_cron? I'm trying to set up a task that periodically deletes backups from my private folder, but I can't properly debug arrays that ...
0
votes
0answers
12 views

How to sort nodes in a view with current language first

How would I sort nodes in a view to show nodes translated to the current language first? This would then show nodes that haven't been translated to the current language after nodes that have been ...
1
vote
2answers
427 views

Controlling a dependent field in a multi-instance paragraph

The fields below are part of the node/add node/edit forms of my custom node type. The paragraph field_para_city contain one field_city. (I later need to add other fields in the paragraph). The user ...
1
vote
1answer
621 views

How do I programmatically render a view that has exposed filters?

I can call a view with contextual filters without any problem, but when I add exposed filter value $view->setExposedInput to the call, I just does not work, the exposed value is not applied and being ...
0
votes
0answers
33 views

Error on cron : Link could not be converted to string [duplicate]

Everytime cron try to run this error appear and everything stops. All I could find is that a Link is passed in filter Xss function when the cron try to index the website search. If I comment the ...
2
votes
3answers
576 views

How to reuses page--front.html.twig for multiple pages

I created a page--front.html.twig which allows me to create a distinctive front page. How would I go about reusing this page to create a landing page, a page with an identical layout the front page ...
-1
votes
0answers
26 views

problem on content on editing [closed]

when I try to enter content on my drupla 8 on structure I get this error Le site Web a rencontré une erreur inattendue. Veuillez essayer de nouveau plus tard.Drupal\Core\Database\...
2
votes
2answers
1k views

Why is cache_render very big?

I am having a big problem with a newly created Drupal 8 site for a theater. After going live we discovered that the cache_render table grown extremely big, and extremely fast. After one weekend, it ...
0
votes
1answer
779 views

Adding custom data to the node object

I have created a content type called providers and when editting said content types users can fill in extra information related to the content. I have included said form fields using hook_form_alter,...
0
votes
1answer
523 views

Error while accessing admin section

I am facing the following error while trying to access Admin section in Drupal 8 (WAMP Server). I tried to install the Update manager module and from then I am facing this error. I am unable to access ...
1
vote
1answer
614 views

How to properly compare values of two identical entities?

I have a custom entity that is not revisionable and I need to store any differences made by the user - and only differences, so if nothing has changed there should be no entry. I am doing this in ...
0
votes
0answers
27 views

How to access the block ID in hook_block_view_alter()?

How can I access the block ID in hook_block_view_alter()? function mysite_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) { if ('my-block-id' == $block->...
1
vote
1answer
48 views

{{ drupal_view('view1', 'block_2') }} renders only when cache is cleared

I like to output 2 block-views in a template called "block--bar.html.twig", but only when i clear the cache they are printed. (i installed Twig Tweak 8.x-2.x) This is the template: <section{{ ...
2
votes
1answer
717 views

Autocomplete textfield displays value when selected and not label

I have a textfield autocomplete field that shows a list of full user names and email addresses as designed but when a user is selected, the user id is displayed in the field; not the name and email ...
1
vote
1answer
22 views

Adding a base field definition in an update hook - it's not appearing

I want to add another base field to a Drupal entity. It used to be possible to just change the code for the entity definition and then update it via the Drupal console. But now it has to be done in an ...
0
votes
0answers
36 views

Exclude node from search API results based on values in existing fields

My content node includes a verified checkbox that's marked by a human reviewer who then also enters a date. The node is verified only when the box is checked and the date is entered. A content node ...
-1
votes
1answer
29 views

Drupal 8 how to translate Entity Types Lables?

Example: Are you sure you want to delete the @entity-type %label? I am able to translate the above string but @entity-type remains not translated like below, Haluatko varmasti poistaa content test? ...
-1
votes
2answers
44 views

Twig define dynamic generate variable

I have field names: field_en_image field_sv_image node_lang is set as a variable in the .theme file under _preprocess_node hook. I want to print the field dynamically in the twig template file ...
0
votes
1answer
377 views

Address Module 8.x-1.3

I am trying to run address field on my web page, but I get an error The website encountered an unexpected error. Please try again later. So I checked the logs and get Error: Class 'CommerceGuys\...
1
vote
1answer
45 views

Twig: How to access multiple values from node reference field with number_format

I'm adding fields to array: {% for item in content.field_notes | field_target_entity %} {% set field_component_pages = item.field_component_pages|view|number_format %} {% endfor %} In my ...
2
votes
1answer
63 views

Why this specific string is untranslatable

I want to translate "You can only change the parent menu item for the published version of this content" which belongs to Menu UI module. The string is defined in /core/modules/menu_ui/src/Plugin/...
21
votes
8answers
21k views

How do I correctly setup caching for my custom block showing content depending on the current node?

I have this very basic block which just shows the current node's ID. <?php /** * @file * Contains \Drupal\mymodule\Plugin\Block\ExampleEmptyBlock. */ namespace Drupal\mymodule\Plugin\Block; ...
-1
votes
1answer
26 views

How can I use Twig tempalte to handle label of form input field?

In a custom module (association), I have a form (MembershipStep3). I'd like to use Twig template to handle form fields titles and need some advice about that. In association.module, I have this code: ...
-2
votes
1answer
18 views

Change Superfish menu on specific pages

Is there any way I can change the menu in Superfish module in specific pages? What I know so far is that Superfish uses the "Main Navigation" in the admin structures by default. Can I create a ...
0
votes
1answer
603 views

printing an entity reference field in a special display mode

I have an entity reference field. The referenced entity has multiple display modes. I'd like to print this field 2 two times in a template, with 2 different display modes like so: {{ content....
0
votes
0answers
10 views

How do you simulate Google login with the Drupal 8 social auth module in ones local server?

I am trying to test Google login in my local machine to capture the event and activate the user automatically. I had run code to simulate the triggering of the event but that might not be authentic ...
-1
votes
0answers
15 views

Download html into pdf using Dompdf. Indian fonts shows up as garbage after download [closed]

I am using Dompdf to download html content into pdf. It works fine for english, but shows garbage texts for Indian fonts.The indian languages that I want to print are already configured into Drupal. ...
1
vote
1answer
603 views

Display content based on URL

I am working on Drupal 8. I have a to display content from a content type on different pages. I am trying to use Views to achieve this. In the content type I added a field to refer to Pages so that ...
0
votes
0answers
24 views

Path to image file in theme folder for use with image_style

How can I use image_style settings on an image in my theme? The twig way I use for images, which are stored in fields is like this, with the help of Twig Tweak and Twig Field Value modules. <!-- ...
0
votes
1answer
529 views

User registration without email address OR registration with pseudo-email address

I am programmatically creating users for the roles Parent (Adult) & Child (minor). During registration, minors (Children) typically will not have email addresses but Drupal user registration ...
2
votes
3answers
760 views

How to remove unwanted div from view rendered block?

In D8 I've created a view and assigned it into a block, I've created corresponding template for both view and block. Most of the unwanted addition of div's and classes has been removed. But the ...
0
votes
1answer
458 views

OpenDialogCommand how to include Buttons in dialog_options

How can I inlcude buttons in OpenDialogCommand? $options = [ 'dialogClass' => 'my-dialog-class', 'width' => '700px', 'buttons' => [ 'text' => '...
0
votes
1answer
891 views

How do I throw values calculated back to buildForm()?

I am trying to throw back values that are calculated in submitForm() to buildForm(). How do I add more state values into it? /**  * @file  * Contains \Drupal\resume\Form\ResumeForm.  ...
0
votes
1answer
12 views

address dependent locality field not shown

drupal 8.8.2 address 8.x-1.7 address module is working in that i can add an address to my content, however I am not able to display the "dependent locality " field even when it is set to "no ...
5
votes
4answers
3k views

How to disable H1 heading in CKeditor?

I'd like to give some authors a better SEO experience. How can I disable Heading 1 in builtin CKeditor in Drupal 8?
0
votes
1answer
11 views

Categories REST API relation with Blog Posts

I am new to Drupal. I am trying to create a news app with Drupal as back end. I created a Category Taxonomy and attached it with Articles Content type. Then I created View for Articles Rest api and I ...
1
vote
1answer
34 views

Difference between creating a Rest endpoint and a route&controller with jsonResponse

What is the difference between creating a Rest plugin with the Rest API and creating a route/controller that returns a jsonResponse ? In which case i have to create a custom route/controller with a ...
1
vote
1answer
73 views

How can you display document file sizes next to a media link button?

I'm trying to display the file size of a file next to a media link button on a page. I have two content types with a media entity reference field in each. Each field is restricted to only pull from a ...
1
vote
1answer
17 views

Use a custom install profile for Nightwatch tests?

How can you set a custom install profile to run a Nightwatch test in? I am not seeing it in the docs. The definition of the .drupalInstall() command has: commandAsWebserver( `php ./scripts/...
5
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.