Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [entities]

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

0
votes
1answer
23 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 ...
0
votes
1answer
10 views

How to use a token in the reference fields

1-I have a node with the name of the project. 2-this node has a project_name field that generates by these Tokens 3- I have a reference field that it load an entity type in the project create the ...
1
vote
0answers
13 views

IEF reference show parent field as title using Auto Entity Label

I am new to Drupal 8 want to add a field value to IEF reference title. for now, I am using Auto Entity Label version 2.x-dev to automatically generate a title for my Entities but when it comes to IEF ...
2
votes
1answer
25 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
13 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
24 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
17 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
24 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
17 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
23 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
29 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
35 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
31 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
38 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: $...
-1
votes
0answers
43 views

Why doesn't entity ID appears in hook_entity_insert?

In a custom module (amap), I have a custom content entity (contract) with standard CRUD functions. In the corresponding module, i have this code: function amap_entity_insert(EntityInterface $entity)...
0
votes
1answer
30 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
20 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
36 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
25 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
35 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
28 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
14 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
48 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
0answers
30 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
20 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
14 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
33 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
22 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
37 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
82 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
22 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 = ...
0
votes
0answers
23 views

How to programmatically add fields to a node through a module

I've followed a tutorial here about adding a field to every taxonomy and node and I'm getting an error on installing it. I can get the field, widget and formatter to work, just can't get it to install....
0
votes
0answers
16 views

Get the field for a value of a “List (integer)” field using entity_load()

I am trying to get the label for a value of a List (integer) field using entity_load(). With the code I am using, I'm able to get the field key with $flagging->field_form_status['und'][0]['value'],...
0
votes
1answer
46 views

Get Entity ID when is saved

I need to capture the entity_id when the entity is saved. The ID will process and insert in a custom field. I use hook_entity_presave(), but when is a new entity the ID is void. Is there any way to ...
0
votes
1answer
25 views

Custom Entity Type and Bundle Creation

I've been building custom entities for a while now, but have been using the entity construction kit (eck) to build them. This has limitations as it requires you to #1 depend on the package for new ...
-2
votes
1answer
19 views

How can I import a CSV file to custom entity created using ECK module?

I have created a custom entity type using ECK module. I want to import a csv file with data to my custom entity. How do I do this?
0
votes
0answers
26 views

Datetime wrong type in database

i'm triying to create an custom entity, to store data i'm creating a schema through BaseFieldDefinition (or some near). The problem is that some fiels of type datetime are created in the database with ...
0
votes
2answers
34 views

How can I see all the places an asset or entity is referenced?

In Drupal 8, I have a requirement from a client that they be able to find a reference of a given asset (file, node, entity, etc) throughout a Drupal site. The ultimate goal is to know that if they ...
0
votes
1answer
31 views

How do I add a customized parameter to image links

Lets say I have image fields in my node. When I get that fields values in the twig it returns the image URL without any issue. file_url(node.field_image.entity.uri.value) But now I want to add a ...
0
votes
2answers
32 views

How to print an entity bundle field from one with multiple values

Struggling to find the answer to this. I have an entity called "school objects" which has a bundle called "homepage". One of the fields attached to this is called "Hero banners" and it allows multiple ...
1
vote
0answers
55 views

How a media image entity_reference field in a custom content entity can be set to translatable?

I created a media image field in my custom entity content: $fields['image'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Promotion image')) ->setDescription(t('...
0
votes
0answers
33 views

Paragraph containing an entity reference field as a select - Show options by something other than label

I have an author content type. I have a book content type. I associate multiple books with an author by having a books paragraph field in the Author create / edit form. In my Book Paragraph field I ...
1
vote
1answer
25 views

Related block by entity reference

I have a 2 content types. Article Page and the Article content type can reference pages from an entity reference field. Now I want to display a block on Article nodes that have a same reference. ...
0
votes
1answer
25 views

How to use entity_reference programatically

i'm building a module with an Company entity, this entity should be linked to other 2 entities and i think that the type "entity_reference" should be useful for this pourpose, but i dont see how ...
0
votes
0answers
25 views

Default entities in reference list

I'm implementing a way for providing documents to different users for download on Drupal 8. Each document has a category (implemented as own nodes). Some categories are global. Some categories are ...
0
votes
0answers
16 views

Migration paths for Webforms or Contact Storage modules

Were there ever existed, or is there an existing tradition to create migration paths for Webforms or Contact Storage modules? I ask this because on the one hand I'm not a PHP programmer and on the ...
0
votes
0answers
18 views

ListBuilder changes are not reflecting

I have a NodeEntityListBuilder class with the following in my buildHeader function: public function buildHeader() { $header = array( 'title' => $this->t('Title'), 'type' =&...
1
vote
0answers
41 views

Should I use custom entity types and custom fields to represent complex data types, or is it better to stick with fields and field collections?

Since D7 is now coming up on EOL I need to begin planning the transition of a complex D7 site to D8/9. There are 2 particular data design issues I want to revisit. Number one is that I have a number ...
-1
votes
1answer
84 views

Save contact form data in the database instead of transferring it to an email account

So far I had to setup email DNS records and an email server, or alternatively, an email proxy by an email account) to transfer my emails from a CMS to my email account: 1. Email DNS records and email ...
0
votes
1answer
40 views

Get a list of all entity reference fields that reference specific entity types

Is there a way to get a list of entity reference fields by field type (similar to what is produced by $all_reference_fields = $this->entityFieldManager->getFieldMapByFieldType('entity_reference')...