Questions tagged [hooks]

Use it for the mechanism that allows to extends module's functionality without editing its code.

Filter by
Sorted by
Tagged with
-3
votes
0answers
18 views

How to show/hide div based on the radio button selection in form alter

I have a content type, having a field with radio buttons. Radio button describes a list of the interest. Field Name: field_interest Field Type: Select List (checkbox-radio enabled in the form display ...
0
votes
1answer
26 views

One field (entity reference - paragraph) with two display modes

I am having issue with displaying one field twice in my template having different display modes. I have a content type basic page with field field_gallery (which is entity reference on paragraph). In ...
0
votes
0answers
10 views

Warning: Attempt to modify property of non-object [closed]

I have created a custom module for updating webform field data, but I am getting the error Warning: Attempt to modify property of non-object in gievances_webform_submission_presave() I am using ...
0
votes
0answers
17 views

Show who published a revision/page - publish history [duplicate]

I would like to know which user published a page or revision of the page and when was it published. Is there something like publish history? In the image we can see only the revision (date and author ...
-1
votes
0answers
12 views

export view to document word

I'm using drupal 8 and i'm looking for module that export the view content or the html page to document word when users(please notice that i want this in page and not in BE ) click on download word ...
0
votes
1answer
28 views

Field contains list and values of it are shown in one symbol

I'm developing a drupal module and there's a problem. I need to make a content type with some fields and one of them should have list with string values. But when I try to create content and choose ...
0
votes
2answers
29 views

How to implement a text field formatter that renders a URL as the image?

If a node has a text field with the url of an image as its value, how can I render this field as the image? The image does exists it will be given the image url. I have to write that url into the ...
0
votes
0answers
8 views

Add a button on the login form

Is it possible to add a button on the basic login form? function alter_form_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if ($form_id == 'user_login_form'...
0
votes
0answers
31 views

Alter a Field Collection display order inside a FieldCollectionHook

I have been stuck in here since yesterday and I'm starting to run out of ideas. I have a Field Collection that contains 2 fields. The first one is a multiple taxonomy term, and the second one is a ...
0
votes
0answers
25 views

User register returns 409 [closed]

I developed a mobile app that interact with the d8 site rest api using the /user/register?_format=json where in some devices the register returned a 409 conflict and the user is not even registered ...
-1
votes
0answers
33 views

hook_form_alter() does not work

I have created a form by web-form module in drupal 7 now I am using a form_alter hook but it is not working here my code function gievances_form_alter(&$form, &$form_state, $form_id) { ...
0
votes
0answers
34 views

How to get identifier for menu link item in form hook?

How to get something unique (like 'menu link id' mlid in Drupal 7) in the form for editing one menu link item? hook_form_alter(&$form, FormStateInterface &$form_state, $form_id) { $mlid=... ...
0
votes
1answer
12 views

Hooking into page specific instance of checkout flow form

I'm working on manipulating the buttons used for the checkout flow of using D8 Commerce 2. I'm using MYMODULE_form_commerce_checkout_flow_multistep_default_alter but its changing both the form buttons ...
0
votes
1answer
59 views

Before login hook

Is there a Drupal 8 hook for pre-login? I would like to redirect the login information of a user on a web server by URL. I know there is hook_user_login(), but this one only looks called once the ...
0
votes
1answer
31 views

Get field machine name inside HOOK_preprocess_file_link()?

I am hoping to get the field name inside the HOOK_preprocess_file_link. Only wanting to alter the link of the file for certain field names. Hook_preprocess_field() would probably work, but would ...
0
votes
0answers
33 views

mymodule_feeds_presave not running

Drupal 8 I have custom module that should alter some parts of feeds but I have no idea why mymodule_feeds_presave() not running at all I am adding mymodule_feeds_presave() in mymodule.module in ...
0
votes
0answers
14 views

Alter Entity Reference data before view is rendered

I am attempting to work around a bug where an Entity Reference Field on User Account is saving duplicate references. I originally tried to remove any duplicates on the field by implementing ...
1
vote
1answer
91 views

Modified user record during presave hook not saving properly

A project I am working on has a bug where an array field on the user object is getting duplicated values. To fix this bug, I am implementing the hook_user_presave hook in one of our custom modules to ...
-1
votes
1answer
14 views

Watchdog in `hook_user_presave` implementation causing unknown error [closed]

In my own module, my_user.module, I am trying to implement the hook_user_presave invoked from user.module. Following the examples, I created a function in my module like so: /** * Implements ...
0
votes
0answers
11 views

Custom facet processor not displaying on facet setting

We have a custom module,mymodule, where we create a custom facet processor for a facet we created (myfacet). When we enable the module and cleared the cache we are not seeing the new processor display....
0
votes
2answers
27 views

How do you use hook_form_FORM_ID_alter() to alter the USER EDIT form?

I'm trying to mark fields on the /user/_uid_/edit screen as disabled. These are custom fields I've created in /admin/config/people/accounts/fields in D8. I have this code for another node entity type....
0
votes
0answers
6 views

Produce array of results from view that has a pager

I am trying to get an array of all the view results in a views_hook_pre_render function. The problem I am running into is that the view has a pager (and needs a pager because it has thousands of ...
1
vote
1answer
43 views

Field collection item code not working

Hi Every one I am trying to create new field collection item programmatically but code is not working. I want to create a number of field collection items but no Luck. My code is following. use ...
1
vote
2answers
58 views

Fetch view results from mymodule_preprocess_page hook

We have a View page that is coming from myview. Using the header setting in the view we have added @total results already, which displays in the views-view--myview--page-1.html.twig using the {{ ...
0
votes
1answer
23 views

Accessing the uri within the template_preprocess_image_formatter

I am using template_preprocess_image_formatter and I am trying to access the uri protected property inside the URL array (see screenshot) does anybody know how to access it?
0
votes
1answer
46 views

How owerride entity node delete core function

I'm doing a headless drupal cms. I need to check the entities before they are deleted. I need to do it globally as the deletion of entities can take place via api (already written) or by using the ...
0
votes
2answers
42 views

How to get all values from a new node being created in hook_ENTITY_TYPE_presave()

Drupal 8.7.2 function mymodule_node_presave(Drupal\Core\Entity\EntityInterface $entity) { data_dump($entity->original); //is empty because its a new node, not a node being updated. // How to ...
0
votes
1answer
62 views

Get Current Applied Image Style Name

How do you get the currently chosen image style name from the field format display option? I can load an image with a given style with the code below, however, the style name (e.g. thumbnail) is hard-...
0
votes
0answers
17 views

How to print contact email in the receipt email?

I've got a question regarding receipt emails. I saw the doc about customization of receipt emails espacially the available theme_hooks. I'll need to get the contact info (email) in the receipt email....
0
votes
0answers
16 views

Zoom API error - Only available for enabled v2 webhooks

I have installed ZoomApi module and also created app in marketplace with JWT. When I am going to webhook page, Its giving error:- ZoomAPI\Exception\ApiException: [400] Error handling response. [...
1
vote
1answer
46 views

Possible to theme the form's elements with own twig?

I was thinking to get twig outputs so I could use these twig variables on a form.html.twig such as below: <div class="row"> <div class="col-md-6"> {{ form.name }} ...
0
votes
2answers
57 views

AJAX callback inside hook_form_alter()

I don't know how to implement AJAX callback in hook_form_alter(). The field is plain text by default and it is populated by NID (number) of the client company. The module name is "my_car". I didn't ...
0
votes
1answer
110 views

Strip html tags in preprocess hook

We have a mytheme.theme file that has a mytheme_preprocess_node(&$variables) function. Within this preprocess hook, we would like to remove all HTML tags within a formatted (long) field. The goal ...
0
votes
1answer
47 views

Hook for Node Add Field?

For my use case, this question revolves around the entities node and paragraph. Fields in my projects are created under the following structure: content_h2 paragraph_h2 content_p paragraph_p ... ...
0
votes
0answers
13 views

How to show external PHP in custom module view?

I have created a custom module which contains the hook_block_view and inside that I'm calling a function which only has this code ( the data.php only contains html and php to print a table ): ...
0
votes
0answers
14 views

Automatically add meta tags on node creation

I'm currently maintaining a lot of different sites containing the same information pages (example: profile pages with the same content but on different sites/base URL) and I'd like to consolidate this ...
1
vote
1answer
47 views

How to use hook_prepare to modify a field of a node before it is edited

I want to modify the contents of a field of an Article node just before it comes up for editing. I have read the documentation at http://api.hostdog.gr/api/drupal-8/drupal%21core%21modules%21node%...
-1
votes
2answers
33 views

CIDRAM on Drupal 7 [closed]

Has anyone installed CIDRAM (access management to block undesirable IP addresses) on Drupal 7. It requires adding a "php require" statement to a file that is executed on every attempt to access the ...
0
votes
2answers
36 views

Get value of programmatically (form_alter) added fields at form submit

I'm altering a node creation form using the form_alter hook in a custom module. In this particular case, I'm adding an email field which is not part of the content type structure. At the node creation,...
1
vote
1answer
21 views

Set value on a new term based on a vocabulary custom field

I want to set the value of a field of a term based on a custom field set on the vocabulary. Basically if the vocabulary promote_to_index field is checked I want to the field_index_page of the term ...
0
votes
1answer
18 views

How do I change the Views (Entity Reference) filter via AJAX?

I have an entity form that allows an admin to select a content type (checkbox) and an autocomplete field that is tapped into a VIEWS Entity Reference (via the Reference Method). Goal: What I would ...
0
votes
0answers
54 views

Error when saving node with submit callback added in form alter [on hold]

Scenario: I am building a Multistep Wizard for two different content type. Magazine Information Magazine Details On 1st Node I have by Default, Save/Submit Button Available. Now i want to add "Save ...
0
votes
1answer
130 views

Get node based target id from entity reference

We have an Article content type which has an Entity Reference field called field_document that is linked to the Media bundle type of Document. In mymodule we need to write a hook that will take the ...
0
votes
0answers
11 views

Is it possible to use hook_views_query_alter to compare the value of two fields?

We have a D8 site with a view that links a Content-->Paragraph-->Content. We also have language translation enabled so the views_ui module displays duplicate rows for all combinations for the content ...
0
votes
0answers
22 views

View presents fewer items per page after using Unset

I'm deleting items by means of an unset in hook_views_post_execute, as far as the view I have it configured by 10 items per page. The problem is that it shows me sometimes 6 or 8, I have searched for ...
0
votes
0answers
35 views

Hooks vs Events vs Extension - when to use what?

Im writing a module. One thing it will do is alter the menu edit form. I've been looking at core code and examples on the internet and can't really figure out when to extend Drupals core classes, use ...
1
vote
1answer
21 views

Which hook to use for updates of all nodes of a particular type

This question is about Drupal 7. For a particular node type, let's take three examples: a) book b) article c) customcontenttype I would like to be able to capture the moment of an update of an ...
0
votes
1answer
30 views

amp-img tag, replace to simple img

I need to change this tag <img> to <amp-img>, I've been researching about this and I have this function for change the img tag. function amptheme_image($variables) { // Remove RDF ...
1
vote
1answer
28 views

How to change image style using hook_views_pre_render()

I am trying to adapt the following Drupal 7 code to Drupal 8, in order to set a different image style to every image in a view: // Assigns a random style name to each image function <MODULE_NAME&...
3
votes
2answers
92 views

Alter webform messages found in WebformMessageManager

List item Is there a way to change the hardcoded webform messages from /webform/src/WebformMessageManager.php? for example, the one on line 284 case WebformMessageManagerInterface::...