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
2
votes
1answer
82 views

How can I mock a class during a functional request that is called from within a controller?

I am working on a custom module that from a controller calls Elastic search and returns a search result. I am trying to write a simple Functional Php Unit test just to make sure the results are ...
0
votes
0answers
21 views

How can I set Focal Point coordinates in a View or Twig?

I use the Focal Point module in D8, and I'm trying to figure out how I can access the X and Y coordinates of the focal point through Twig in either a view or Twig template so I can use them as ...
0
votes
0answers
15 views

Longer text doesn't translate in custom module

I have built a simple module that contains several modules. Each shows a page with some descriptive text, a form and a result table. The result table is populated using the input and some calculations ...
0
votes
0answers
17 views

Webform Confirmation Page URL alias tokens

From several things I have read, it seems like I have this correct, but it doesn't seem to be working. On my form settings page under "Confirmation page URL alias", I have: /quote/thank-you?loc=[...
1
vote
1answer
50 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{{ ...
0
votes
0answers
42 views

Sort by term references matches

I'm using Drupal 8, the Search API module and SolR. I have a content type (Page) and a taxonomy term reference field. A page can have multiple tags. When I search pages with Search API, i can't find ...
-2
votes
1answer
29 views

How to query a custom content entity with fields added with UI?

In a custom module (assoc), I have a custom Content Entity (Person) with some fields: $fields['lastname'] = BaseFieldDefinition::create('string') $fields['firstname'] = BaseFieldDefinition::create('...
1
vote
2answers
62 views

How do I configure a Kernel test?

Currently I am able to run the Unit test from the below command C:\Acquia_dev_desktop\LocalInstance\drupal_new_lab\vendor\bin>phpunit -c ../../core/phpunit.xml.dist ../../modules/custom/lse_demo/...
0
votes
1answer
78 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(); ...
0
votes
0answers
33 views

Why the function hook_form_alter doesn't work on admin forms?

In my custom module .module file I implemented hook_form_alter thus: function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { \Drupal::messenger(...
0
votes
0answers
41 views

How do I access the parts of twig.html arrays that start with a #?

I am trying to make an html.twig file and change how a paragraph renders its content, but I can't access the part of the array that has the info I need. This is the vardumper line I used to get this ...
0
votes
1answer
48 views

How to render element array piece by piece

I have template form.html.twig Drupal commerce is using it to render cart form. I made override of that template, to be able to change it only for cart form, without affecting other forms. That part ...
0
votes
0answers
12 views

Webform using latitude and longitude from algolia places as context parameter for entity reference view

I have a webform in which I use a location field (algolia places). By typing the address into the field I'm getting the latitude and longitude values provided by the library. Now I want to start a ...
-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? ...
0
votes
1answer
15 views

Explicitly passing argument to local action for access check

I'm using the group module, and in a custom module I'm trying to create a local task that will bring you directly to the create page for a particular group content type. My goal is to skip the create ...
0
votes
1answer
34 views

hook_form_FORM_ID_alter in theme file to toggle field visibility

I have a boolean check box that I want to control the visibility of an entity-reference field below it. By default, this check box is unchecked, which means the entity-reference field should not be ...
0
votes
0answers
16 views

How to place a view under a local task tab?

For my Drupal 8 project for user view /user/* I have created one custom tab in the local tasks "Manage school": $data['tabs'][0]['user.manage_school'] = array( '#theme' => 'menu_local_task',...
0
votes
0answers
28 views

setErrorByName not working properly if field is in #details

In a form, some fields are defined in '#details': $form['person2'] = [ '#type' => 'details', '#title' => t('Person2'), ]; $form['person2']['lastname2'] = [ '#type' => 'textfield', '#...
0
votes
2answers
38 views

Download file after filling a form [closed]

On my site, the visitors can download whitepapers as pdf. I would like to gather some information before handing over the file. Updates: the downloads should be open to unregistered users What I ...
0
votes
1answer
26 views

View should show related articles from shared reference field - relation from a relation

I have two content types: Article and Magazine. in Article there's an entity reference field to Magazine, field_related_magazines. On my website, when an article is shown, I would like to show a list ...
0
votes
1answer
24 views

Should a splash page linking to other multisite instances also be a multisite instance or a bare HTML page?

This is the situation: Global domain: www.domain.com (exists of one page, with links to other 3 subdomains) Sub domain 1: sub1.domain.com (full website) Sub domain 2: sub2.domain.com (full website) ...
0
votes
1answer
31 views

How can I generate custom XML for a SOAP client?

Im building a SOAP client that consumes from a SOAP web services in a Drupal 8 module. I need to generate this final XML: $inpunt_data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap....
-3
votes
1answer
32 views

Find the current node title from my custom module

I'm working on a simple custom module (Drupal 8). How can I get the title of the current node and use it in module's template twig file (or pass it to twig file through PHP)?
0
votes
1answer
22 views

How can I print the file size and other file info in a Views field template?

I have created a content type with a number of fields including file fields. In the node template for that CT (node--unit.html.twig) I am able to get the details with the following code: {% if ...
0
votes
0answers
10 views

Reference field on Taxonomy term for selecting one of all nodes using the term

I have a taxonomy called categories. Node type article can use these terms. In the term edit form I would like to be able to select one of all nodes using the term (to pick one main article for each ...
0
votes
1answer
37 views

Disable cache on base url for redirecting unauthenticated users

I am trying to redirect unauthenticated users. So anytime an unauthenticated user tries to get to the base url, redirect them to an external url. Currently works, but continues to redirect to the ...
1
vote
5answers
517 views

composer won't update 8.7.10 to 8.8.2 - “Nothing to install or update”

When I try to use composer to update Drupal, it fails to follow through, and gives me several abandoned items. Not sure where to go from here, but maybe someone can give pointers on what might be ...
0
votes
0answers
16 views

How to repair a field storage configuration problem for a group?

After a cron run, the following message is appearing in watchdog. Drupal\Core\Field\FieldException: Attempt to create a field field_description that does not exist on entity type group. in Drupal\...
0
votes
0answers
25 views

How to print multi step webform current step number from webform page template?

I have template named page--webform.tpl.twig which is kind of wrapper for multistep webform. I would like to print current step of the webform from that template. Is there a way to access current ...
0
votes
1answer
23 views

How can you prepopulate a field based on another field's value?

this one was easy in Drupal 7. I defined a condition "If field A has value B, then field X will automatically get value Y". How can I get this working for a Drupal 8 webform?
0
votes
0answers
37 views

How to install a composer library into a custom folder [duplicate]

I want to add the PayPal SDK with my custom module in Drupal 8. It works if I add "paypal/paypal-checkout-sdk": "^1.0" in the root composer but obviously it downloads the PHP SDK in the vendor folder....
0
votes
2answers
45 views

Cron error message. table or view not found: 1146

In watchdog I am seeing an error when cron is run. Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tdtvnksvps.field_deleted_data_38d3088921'...
0
votes
0answers
26 views

AMP page with recaptcha on webform [closed]

I have an AMP page with a webform on, and a recaptcha v2 before submit it. But with AMP, only recaptcha v3 is available (because v2 add an additional script, and it's not accepted by AMP). So I ...
0
votes
0answers
23 views

How can you calculate shipping costs by weight and city? [closed]

I am using commerce in drupal 8. What I need is to add some conditions in shipping cost like the following: if the weight is less or equal to 3kg then: For Athens 5.00€, Outside Athens 6.00€ ...
0
votes
0answers
14 views

Node values not retrieving properly in .theme and Twig files

I created a content type and have a couple of fields: a heading, links, and images. After creating a node out that content type, I want to pull parts of the node into my homepage. And for that, I used ...
0
votes
1answer
59 views

Why is the programmatically removed paragraph item still showing after adding a new paragraph to the node?

I have a paragraph field in a node with unlimited add paragraph. I am removing these paragraph programatically. Its removing but when I am adding a new paragraph its adding blank paragraph along with. ...
-1
votes
0answers
18 views

Using Access Filter Module to redirect unauthenticated user to an external site

Here's the module: https://www.drupal.org/project/access_filter Wondering how/if I can use this module to redirect an unauthenticated user to an external site when they attempt to access a certain ...
3
votes
1answer
52 views

Where do I find the comment IP address?

I am searching for comments ip address in D8 and I can't find where they are located in database. In D7 it was easy to find. Is there a chance that D8 is not storing the commenters ip address? If it ...
0
votes
0answers
15 views

Whats the file structure and correct implementation of using StackMiddlware for a redirection? [duplicate]

I'm currently using an EventSubscriber to successfully redirect unauthenticated users from my site. However, the redirection still takes place on that specific page even after the user is logged in ...
0
votes
0answers
7 views

Using Open Live Writer for Drupal 8

Is there any way to use Open Live Writer (or a similar tool) with Drupal 8? I found this other question, which mentions Atom Publishing Service, but that doesn't seem to be fully supported.
2
votes
0answers
46 views

How to implement StackMiddleware for a redirection correctly?

I'm working on a redirection (for unauthenticated users) for my Drupal 8 site. Currently, the redirection works however, the redirection persists even after user is authenticated. I found this article ...
-3
votes
1answer
28 views

Which modules missing from filesystem

A few contrib modules from Drupal 8 multisite were deleted from /modules. Websites are now of course off. I need to reinstall every module required from websites in /sites How can I get a list of ...
0
votes
0answers
12 views

How to you force form modes to inherit field settings (like required/not required)?

I have created a new form mode for a site's image media type. Am able to ensure users are using that form, but for some reason it doesn't enforce any fields that are marked as required in the media ...
1
vote
2answers
29 views

How do I assert for a link's href AND link text in a functional test?

In a functional test, I can use WebAssert::linkByHrefExists() to check that a link with a specific href exists on the page. And I can use WebAssert::linkExists() to check that a link with a specific ...
0
votes
1answer
27 views

On content, choose the taxonomy parent and display all the children

I have a content type with a taxonomy field based on a hierarchical taxonomy with 3 levels. I use Simple Hierarchical Select (SHS) to select and display the terms. I want to have a view that ...
-2
votes
0answers
18 views

How to create form for single field from user content type?

Drupal has a user content type to save registered user's datas. I created a file field on the user content type to get some file from the logged in users. I want to display the file field separately ...
0
votes
0answers
23 views

Execute custom JS after sucessful submit of AJAX contact form

Perhaps it's all simple but can't find out the exact solution. I have several Drupal's core contact forms on my web site. For example: #contact-message-form1-form #contact-message-form2-form #...
1
vote
0answers
33 views

How to schedule content every Wednesday at 18.00 (6 PM)?

Looking for something which was easy in Drupal 7, but can't find it or can't get it to work in Drupal 8. import feed do not publish content immediately run a rule that sets the content to publish ...
-1
votes
0answers
28 views

How do I save file in the database using custom form in drupal 8?

I created a custom form to get resume file from user and save it to their profile. My custom form looks like this, $form['resume'] = array( '#type' => 'managed_file', '#title' ...
0
votes
1answer
13 views

Combined Fields filters and missing custom search api fields

Drupal 8 I am using Search API and Views to search several fields from several content and media types. For example, I have a custom "description" field for Media->files so users can add a searchable ...