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

How to restrict/provide access to particular entities of some ENTITY_TYPE to users which has email listed as field value?

I have a entity type Products with multiple entities in it. I want to give View, Edit, Delete Access of each entity to users only whose Emails are listed under field_user_email. I want to restrict ...
0
votes
1answer
104 views

Get node data from entity reference field

I have an entity reference field to a content type blog. I referenced a specific blog, but when I render that field in twig using {{ content.field_blog }}. I want to get the autor name and time when ...
1
vote
1answer
70 views

Newly created fields are not being displayed

I have a content type "Article" with fields and data that was migrated from a Drupal 7 website. In the admin/structure/types/manage/article/fields I added a new text field called "Test" with default ...
0
votes
1answer
27 views

Programatically copy an image from user entity to webform submission entity [closed]

Using a custom webform handler, I am trying to copy an image from the image field (field_usr_avatar_img) located at the user account page to the image element (avatar_img) located at the webform ...
0
votes
0answers
34 views

Service decorator for entity list builder?

Is it possible to use a service decorator, or similar mechanism, to override a method in an entity's list builder? For my specific use case, I want to override the render() method of the Drupal\...
0
votes
1answer
280 views

How to print the relative url or node id for each referenced node in twig?

I am using paragraphs to render a number of nodes on a page. The nodes are obtained through an entity reference field called 'field_nodeslist' in my cards paragraph type. The cards are then rendered ...
0
votes
1answer
47 views

Provide autocomplete field with user's Display Name

Drupal core already supports autocompletion of username fields. However is there a way to provide autocomplete for user's Display Name? Since this is a virtual field, a database query with % like ...
1
vote
1answer
54 views

In code, only create a revision if a field is changed

I have a custom revisionable entity with a few dozen fields. I'm importing data about the entity on a periodic basis. If the entity has changed, I'd like to save it and create a new revision. $dogs =...
0
votes
1answer
74 views

Entity getOwner()

In what table does an entity "foo" get its metadata stored? In Drupal 7, there are tables for all the fields for a content type and the node table had some metadata stored, but most data for a content ...
1
vote
2answers
97 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 ...
2
votes
3answers
2k views

How do I perform outstanding entity updates after 8.7?

I have just tested the update to 8.7.1 (from 8.6.x) which includes the removal of the old automatic entity update functionality, which means drush entup no longer works. As far as I understand the ...
0
votes
0answers
11 views

How to compute field value of another content type using compute field module?

I have two content types. Let's call them "A" and "B". A has nodes with field_cost B has nodes with field_total_cost Content type A has a field_costumer which is referenced to the entity of Content ...
1
vote
1answer
20 views

Refreshing entity definition

I've got a D8 media type that holds information obtained from an external source. The information comes in name value pairs that I wish to save as individual fields, mostly so I can index them easily ...
-1
votes
2answers
140 views

Search by reference field target ID [closed]

I have a Project content type, which has a reference field to a Contact entity that has a Client bundle. I can get the reference target ID from the node. I want to find the nodes that contain a ...
0
votes
0answers
22 views

I accidentally deleted basic_cart_vat, there's a way to a restore this field?

I accidentally deleted the field basic_cart_vat from Orders, now I'm receiving an error because I don't have the field. InvalidArgumentException: Field basic_cart_vat is unknown. in Drupal\Core\...
0
votes
2answers
26 views

Create a view on a entity using criteria on another entity

I'm trying to this done : I have two entities 1) Listing Details 2) Listing Premium Settings. This entity references the first Listing Details entity. In the second Entity I have referenced entity ...
0
votes
1answer
127 views

How can I get all fields and values of a node at once?

I know how to get a particular field (title field) of a node by following code: $publications = \Drupal::entityManager()->getStorage('node')->load($node_id); $title = $publications->getTitle(...
1
vote
1answer
975 views

Running drush entity:updates claimed successful but not changing anything

I am working on a project with custom entity type. My module works fine in my local environment. But when I deployed to my staging site, things are strange. For instance, I tried to change my entity ...
-3
votes
1answer
143 views

Getting an error while updating core to version 8.7.0

When update Drupal 8.6 to 8.7 getting the following error. Anyone help would be appreciated. TypeError: Argument 3 passed to Drupal\views\EntityViewsData::mapFieldDefinition() must implement ...
0
votes
0answers
27 views

Data storage for custom config-entity sequence type

Using Drupal 8 I've got a custom content type application and a ConfigEntityType application_type for bundles of it. I need each bundle to store a list of strings when newly created/edited. E.g. ...
0
votes
1answer
35 views

How do I know what setSetting is suppose to be?

I am creating a custom content entity and in the BaseFieldDefinitions, I am trying to create a field for assigning a user as the designated assigner and will follow up with a assignee. So far, the ...
0
votes
0answers
30 views

How to handle submit of a form that extends RegisterForm?

I have a form that extends the native RegisterForm When this form is submitted, I would like to register a user, but then I would also like to store the uuid & certain fields like name & ...
0
votes
1answer
29 views

How do you populate existing entities with the default value for a newly added field?

Let's say I have a content type, Article, with several fields. I already have hundreds of Article nodes created, but now I want to add a new field. After I set a default value for this field, how can ...
2
votes
1answer
27 views

Is there a generic method to retrieve entity IDs?

I have seen this code suggesting how to return a list of entity IDs: $query = \Drupal::entityQuery('node'); $query->condition('type', $bundle); $entity_ids = $query->execute(); but this ...
0
votes
0answers
19 views

Programmatically add field collection item (child) into a existing field collection item (parent)

I have a nested field collection item, field_collection_parent which contains one field_text and a field collection field_collection_child contains two text fields(field_a and field_b). Now I'm ...
0
votes
0answers
25 views

Use autocomplete with an infinite cardinality

I am trying to attach a list of users to a new entity I am creating. I want to enable autocomplete on those fields but I can't get it to work. For the moment, my field looks like this : array( ...
0
votes
1answer
224 views

Display multi-value entity reference field in node edit form as draggable?

Is there a way to display a multi-value entity reference field as a draggable widget in a node edit form? I'm looking for the exact same behavior that a multi-value image field has by default. I would ...
0
votes
0answers
144 views

Updating a module results in a Mismatched entity and/or field definitions with live server only

Installing updates produces Mismatched entity and/or field definitions, yet only within the live server instance. Local environment works as expected. It first happened with the update 8001 in both ...
0
votes
0answers
20 views

no default store (drupal commerce 1.x)

Is there a way to adjust or add the "default store" value directly in a SQL table? I have no default store listed - if it is applicable to version 1.x and all the products I imported from Ubercart ...
0
votes
0answers
36 views

How to install the module Entity Browser?

I'm trying to install the Entity Browser module, but I'm getting this error: It basically says that the "entity_browser" entity type does not exist, and based on the error I tried to install the ...
0
votes
0answers
49 views

How can I replace static file and media links in content with their equivalent entity references?

I imported content from another system. So, for example, the body has typical html, like this: <img src="/images/image.jpg /> All of the media assets that are referenced as static html, those ...
0
votes
1answer
45 views

Referenced entities show old value when changing properties

I have three custom entities, all generated with Drupal Console. I only added some basicFieldDefinitions to them before testing some CRUD operations on them. I have these entities: ConfigEntity (...
0
votes
1answer
34 views

How Can I do a content type with a 1:n field inside?

I'm a bit lost about how Drupal manage content. For example, I want to create a new content type called Game. When I create a "Game" I want to introduce "Platform" and "Release date". For example: ...
1
vote
1answer
65 views

Why is file_managed not updated correctly?

In a custom module (amap), I have a custom content entity (contract) created with Drupal Console. There are standard CRUD functions on this entity. One of the fields of the entity is a file field: $...
0
votes
1answer
35 views

Adding fields to user registration form for admins

I use the Entity Registration module and I created a registration form for specific events in a Drupal 7 site. For the registered users, the fields are name, surname, birth date, upload administrative ...
0
votes
1answer
43 views

How do I get the weight of a multiple value field collection in a computed field?

I have the following structure in a content type: . field_collection_parent (multiple value = 7) .. computed field (single value) .. field_collection_child (unlimited multiple value) ...
1
vote
1answer
197 views

How to get a field third party settings for every content entity forms

Can someone explain or post an example of how to get a third party field settings on every content entity forms? I'm looking for a generic code where a form can be customized (like calling a custom ...
0
votes
0answers
26 views

Default value for image field not accessible [duplicate]

I have added a field to content types so that users can upload a custom background image based on content type. This is a Drupal 8 site. The field is set as required and has a default image uploaded ...
0
votes
0answers
50 views

Error when removing fields from entity

For any reason I receive this ugly message every time when removing a field from an entity. No matter if the entity is a node or a paragraph. The error message makes no sense, as removing a field ...
0
votes
0answers
34 views

Efficient way to get entity information

Which is an efficient way to fetch entity label and id? Database query or entity query with entity load? I need to get the list of all taxonomy terms in an associative array of ID and Label. I can ...
0
votes
0answers
20 views

How to pick up node context in a block to prepopulate entity references in node add link

Let's say I'm building a genealogy site, where I'm displaying an Individual (node 15), that belongs to an Organic Group instantiated as "My Family Album" (node 8). I want to have a side panel block, ...
0
votes
1answer
172 views

Change target type of entity reference field in update hook

In an update function, I'm trying to change the target_type of an entity reference field, following the approach outlined on https://www.drupal.org/node/2535476). The previously used target entity ...
2
votes
1answer
75 views

How can I add entity base field with unique constraint if some entities already exist?

The issue is that adding a base field to a custom entity type in code would result in an issue of unique constraint violation as there does not seem to be a way to preset the value to the newly added ...
0
votes
1answer
88 views

Add preview button on Taxonomy add/edit term form

As we know that entity type node has preview button option which can be used during adding or editing of a node, to preview content. Same feature is missing in case of Taxonomy entity. If I want ...
1
vote
0answers
19 views

Custom Content Entity Type: links annotation

I created a Custom Content Entity Type with all the basic CRUD operations. It is working but I do not understand how the links work in the entity annotation and therefore not why they are necessary. ...
0
votes
0answers
98 views

Use a custom Table/Storage for a Custom Field

I want to create a DR8 content field, which has no field tables, and passes the save and load mechanisms to a custom table. Is there a way to do this? I've been able to prevent saving with: class ...
1
vote
0answers
31 views

EntityFieldQuery: Filter by field language

How would I use EntityFieldQuery->fieldCondition() or similar to filter by field language? E.g. give me all nodes where field_description has items in English, or in LANGUAGE_NONE? There is a $...
0
votes
2answers
88 views

Update node revision time in hook_entity_presave

In my site Drupal 8, I have custom entities (say components) and bundles. I load these entities in a node using the Inline entity module. On the front-end, the contextual links provide two edit links: ...
4
votes
2answers
245 views

Bidirectional entity relationships?

I am doing a migration right now and have a need to maintain how entities are related in a way that the core entity reference field does not seem to support. Lets say I have two content types, Foo ...
0
votes
1answer
30 views

How do I retrieve media from a reference field?

Inside a node type, I have a reference field to target a media. With a db select, I need to load all related medias of the nodes. For this I use this code: $database = \Drupal::database(); $result = ...