Questions tagged [entities]

Nodes, comments, taxonomy terms, and users, in the terminology used since Drupal 7, are generally called "entities."

Filter by
Sorted by
Tagged with
0
votes
1answer
273 views

Create Custom Select Webform Element

I asked this last time with 'Select Other', but I am still not understanding how to change custom element's type. In this scenario, I am attempting to build a Select type webform element. I am reusing ...
-1
votes
1answer
61 views

How to automatically flag entities once (without PHP error)?

I created a custom module to automatically flag new entities and update entities. It works :-) Here is the problem : If I update a neud it is flagged. Perfect that's what I want to do, but if I update ...
0
votes
2answers
64 views

How do you target a specific type of content?

I have the content type (node), article, page, recipe. The code below can be used to flag any type of content. How do you target a specific type of content ? For example I only want to flag the ...
0
votes
0answers
30 views

how easy it is to get the date when the order is completed?

I need to get the due date (payment) of the last order, but I got some kind of crooked code. I receive all user orders by request. $allOrders = \Drupal::entityTypeManager()->getStorage('...
-2
votes
1answer
60 views

Cannot flag nodes and comments automatically

I created a code to automatically flag nodes and comments. When I put only the code to flag the nodes, it works. But when I add the code to flag the comments it doesn't work anymore. Which code should ...
0
votes
0answers
78 views

Override fieldset.html.twig

I am having some trouble understanding the concept of overriding twig templates. I have turned on debugging mode and most of the time I see overriding suggested file names like this: <!-- FILE NAME ...
0
votes
2answers
35 views

How do I limit access to a custom field type I have created so that it can only be attached to certain bundles of content?

I have a custom field class. I would like to limit it to specific content types and bundles that I will choose when my custom module is installed and as other content types meet certain criteria. I ...
0
votes
1answer
123 views

How to flag an entity when it is created or updated?

I have a Drupal 8 site with the Flag module. I want when a user creates or updates a node, product, store, group, ... the updated entity is flagged. How to flag an entity when it is created or updated ...
0
votes
0answers
40 views

Add field to menu link content

I am trying to add a list field to the menu links. I have executed the database update and it creates the field in the "menu_link_content_data" table correctly. But when I go to the menu ...
1
vote
3answers
175 views

How to clear image (or file) field data for specific node programmatically?

I need to clear/remove image (or file) field from specific node. I have before: I want to get after code execution for the field: What code should I use to properly clear image (file) field data?
0
votes
0answers
39 views

Change $form attribute in a callback

I have a form and a field model. In a hook alter, I add ajax callback to a function getMobileorFixed that does some taxonomy computation. Here is the hook_alter function THEME_form_FORM_ID_alter(&$...
0
votes
1answer
23 views

How should a custom configuration entity define a dependency on other configuration?

In a custom module I am defining a defaults Configuration entity that references a role. I would like to define a dependency on the role. This is my first attempt. public function ...
0
votes
1answer
80 views

How to use DefaultSelection::getReferenceableEntities in custom controller?

My Goal: I want to create a customized entity_autocomplete form field to better fit my needs compared to the default one - making some modifications to the HTML and JS that's being used, as well as ...
1
vote
0answers
40 views

Database dump without revisions?

Are there methods to exclude revision data in a database dump? The purpose would be to reduce the file size for developers that want a db dump for local development. I know that drush sql-dump has an ...
0
votes
1answer
31 views

Have a child node inherit taxonomy from a parent during /node/add?

In Drupal 7, I have two content types: Parent Events with tags (like "outdoors" or "popular" or "suitable for kids"). "Tags" are taxonomy terms in a vocabulary,...
0
votes
0answers
26 views

Entity Query returns incorrect results while running functional javascript test

Im writing a functional javascript test for my project where im facing a problem with my feature. I have created a group entity just above it and referencing a parent group. This doesn't work: $...
0
votes
1answer
118 views

The commerce_product.field_produit_labels field needs to be updated

almost every time I delete a field in my product types I get this message popping up in my dashboard : ENTITY/FIELD DEFINITIONS Mismatched entity and/or field definitions The following changes were ...
-1
votes
1answer
32 views

How to load ConfigEntity by Field?

I'm using ConfigEntity and on this Entity, there is a boolean Field (checkbox) called "Published". Now I want to load all Entities with field Published = 1 Do you know how I can do that? P.s....
0
votes
0answers
34 views

how to look_up a user migration with the article migration?

I migrate all the article of an old blog to drupal new website i have my image_migration : id: image label: "Migrate all media" migration_group: image_migration source: plugin: image ...
1
vote
1answer
121 views

How to add revisions tab to a custom content entity and list revisions?

I've just created/generated a custom content entity module using Drush. I've checked I would like to use revisions, but I cannot see its tab. How can I add the revisions tab to this custom content ...
1
vote
1answer
82 views

Manually removing an orphaned entity type

I have been handed an older Drupal 8 site and asked to update it to run with composer. I didn't do it in the cleanest possible way but it is working. I have run into trouble updating it. I am most of ...
0
votes
2answers
62 views

How can I change a content entity to a config entity?

I created a project using Content Entity but now I need to change this entity to Config Entity. Do you know how I can do this?
0
votes
0answers
26 views

Can I get all the possible values of a field of a content type

I've got a field on a content type that is a taxonomy reference with multiple terms. I'm trying to pull all this values from my custom module config so I can limit my module only displaying on ...
0
votes
1answer
199 views

Missing bundle entity, entity type paragraphs_type from field_instance.yml file

I'm currently trying to migrate my D7 site to D8 and one of the things migrating is field_collections to paragraphs. I have a field_collection call "field_sidebar_callouts". I want to ...
-1
votes
1answer
148 views

Get an entity reference's field values in its field template

I have an entity reference field and the template field--my-custom-entity--field-my-entity-reference.html.twig In the template I print the content. {% for item in items %} {{ item.content }} {% ...
1
vote
1answer
265 views

Paragraph's fields value loaded in a custom controller are in the default language instead of the current language

I made a custom controller that load a paragraph field from a node and then render some part in a template. The paragraph field field_title and field_description are translatable. The translation ...
0
votes
1answer
414 views

How to get the entity ID in a twig template

I have a custom entity, with the template my-custom-entity--my-entity.html.twig. How do I access the ID in the template? I can do this by implementing hook_preprocess_entity, but am wondering if the ...
4
votes
1answer
94 views

Load nodes by property, including empty ones

I want to render a node with certain properties set. For example, I want to load every node which ONLY has field_a and the other fields are empty. If I use $this->nodeStorage->loadByProperties(['...
1
vote
1answer
82 views

Using container element in form widget

I want to build a widget for a own field type. In the function formElement() of my widget I want the elements wrapped in a div. For this purpose exists the container element. So I build my form: ...
1
vote
0answers
167 views

The SQL storage cannot change the schema for an existing field (id in sms_phone_number_verification entity) with data

I am using the SMS Framework module and after updating my site from Drupal core 8.8.8 to Drupal Core 8.9.3 and the SMS Framework module from 8.x-1.3 to 8.x-2.0.0-alpha1, I start seeing the below error ...
0
votes
0answers
28 views

Access custom fields on account of current logged in user [duplicate]

I am trying to do something which seems like it would be pretty damn simple, yet I can't get to work; access a custom field (added via the UI at /admin/config/people/accounts/fields), for the current ...
2
votes
1answer
50 views

Getting latest entity data from the database

The problem: I open a drush php:cli shell and run the following: >>> \Drupal::entityTypeManager()->getStorage('paragraph')->load(477)->get('field_end_time')->getValue()[0]['value']...
0
votes
1answer
76 views

Generic field.html.twig template for a custom Entity

I have a custom Entity called custom_entity, along with a custom module which provides twig templates for my bundles and their fields. How can I define a generic/base field template for all fields ...
0
votes
1answer
39 views

How to create block to list all children of an entity?

I want to list all the nodes that have the currently viewed node as their parent. To make this more tangible and less abstract, let's do an example: I have a content type Locations which has an ...
0
votes
2answers
217 views

How to programmatically associate a taxonomy term to a field

I'm trying to import user profiles data from a JSON file. Several fields are entity reference to vocabularies. I'm able to create a new taxonomy term entity in the universities vocabulary bundle ...
0
votes
0answers
16 views

How do you map a Salesforce master detail field to a field?

I have successfully mapped all fields except company name which is a master-detail field in Salesforce. This field is required to make a record in Salesforce. What field should be used to map to this ...
3
votes
1answer
60 views

Why is the output from getDefinition($type) different from getStorage($type)->getEntityType()?

In a Controller, when calling: $this->entityTypeManager()->getStorage($type)->getEntityType(), I do not have the exact same return value as: $this->entityTypeManager()->getDefinition($...
-1
votes
1answer
30 views

Checking whether an arbitrary field is valid for user entity

In my module I have a form where I want to give an admin the ability to configure which user field they want to put certain data in. In the context of the admin form, I'd like to verify that the field ...
1
vote
1answer
39 views

Exclude entities currently referenced on a node with entity browser

I have content type that references a custom entity and uses an entity browser widget to select them. I want to create a view for the entity browser that excludes entities that have already been ...
1
vote
0answers
61 views

hook_entity_predelete never called

I have tried to create a hook that deletes an entity of type notification when the entity of type deadline is deleted, but the hook never gets called. Entities of type notification have one referenced ...
0
votes
0answers
14 views

Unable to add field in administer field tab

I am trying to add fields in Drupal 8 to a existing entitiy. The "administer field" tab is visible but the button for adding fields is missing there. The button is also missing when creating ...
1
vote
0answers
306 views

How do I migrate node entity references?

I would like to migrate node entity references from D7 to D8. In my D7 application, many nodes are related to other with the "entity reference" system. But related nodes could belong to many ...
2
votes
1answer
49 views

How to render a node on behalf of another user (as an admin or without accessCheck)

Context : I use the following code to replace a token by a rendered node. The resulted text is sent by email $renderable = $view_builder->view($node, 'token', $langcode); $replacements[$original] = ...
0
votes
0answers
12 views

default image not showing

I have a entity reference setup in a block that uses the media gallery. I'm trying to get the default image to work which currently if I upload image and it shows but the default image doesn't show if ...
0
votes
1answer
28 views

Entitybrower access denied for non-admin user

I have created an entity browser for taxonomy terms that is used as an entity reference select form element on a node. This allows users to browse terms grouped by vocabulary, see synonyms etc. The ...
0
votes
0answers
12 views

8 Field autocomplete hook [duplicate]

Is there a hook available to modify / alter the title of content in this list ? It's a autocomplete widget. I just want to add the content type.
1
vote
1answer
37 views

How to programmatically reference entities?

I am trying to reference an entity within my hook, so that every time a new entity is inserted, I create another entity referencing the first entity. I have not yet found a working way to reference an ...
0
votes
0answers
21 views

Incorrect field of a content type in its display after migrating from a backup

The following two screen shots should explain the issue well: Here I have a content type Poll, where the first field is Question with machine name title. However, in Managage Display tab, the second ...
0
votes
2answers
66 views

How do I add a filter to a checkbox list in a content editing form

I have a taxonomy select field within a node form (7). I've chosen checkboxes and it is hard to scan them. I'd like to be able to add a filter so that the user can enter text to limit the number of ...
0
votes
2answers
101 views

How to create new entity within a hook?

I am trying to create a hook that creates a new entity('Notification') when an entity of another type is created (either of type 'Deadline' or 'Message'), but I can't seem to figure out how to add a ...