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
57 views

How can I get the parent node of a referenced node?

I have a node called project which contains field building as a referenced item, I used the the hook on building node insert and, having this building id I need to get project id which this building ...
0
votes
1answer
12 views

Entity wrapper save using db_transaction()?

I am using a db_transaction() for some data updates. I am using some EntityMetadataWrappers, modify some data, then save. The thing is, the wrapper ->save() function doesn't have a parameter for $...
0
votes
0answers
20 views

Update Entity Reference View based on form field selection

I have a Content Type called Licence which has two fields, field_product and field_billing_cycle. Both are Entity Reference fields, using the select Widget. The product content type has a multi value ...
0
votes
1answer
27 views

Entity reference and associated data

Assuming I have two distinct entities A and B, with B having an Entity Reference field to A, how can I associate other data (=other fields) with the Entity Reference? For example, assume that A is "...
0
votes
3answers
36 views

How can I tell if a config entity hasn’t been saved yet? [closed]

How can I tell if a config entity hasn’t been saved yet?
0
votes
0answers
70 views

How do I generate a custom content entity bundle?

I created a custom content entity with Drupal console version 1.9.2. Everything is working fine. To use all the configuration and settings of my custom entity type in different bundles, I want ...
0
votes
0answers
19 views

Serialization of dependencies

I'm using Drupal 8.6 and I'm doing the serialization of a node. This node has related fields, which I also would like to serialize. In my case I have an article which has a photo gallery which has ...
0
votes
0answers
29 views

How to register a custom function for labelCallbacks for an existing entity?

I learned that in EntityBase the label method gets called to determine the label for an entity, for instance when it is rendered via the entity reference module as label. Now, for specific node types ...
0
votes
1answer
27 views

How to show a field value instead of the node title for nodes displayed through an entity reference field?

Edit: I think I found the place, just not the method yet. If correct, I will close this question. Sorry. I have no clue which hook or direction to look into. I would like to have a label or title ...
0
votes
0answers
27 views

how to submit multiple value in custom entity in drupal 8?

If I submit single value from dropdown of custom entity field then it will save in data in db. below is the code, working fine. $fields['participants'] = BaseFieldDefinition::create('entity_reference'...
0
votes
0answers
13 views

Cant get Quick Edit Link to display on Published Content

I am having a problem with the Quick edit link displaying on published content? Is this working as designed or am I missing something. The quick Edit link appears on all of the unpublished content. ...
1
vote
0answers
98 views

Change field type for custom entity (from integer to decimal) with existing data

Yes I have seen previous answers about that, but I'm looking for an new answer : That does not use SQL request That does not use deprecated function like db_change_field() maybe that uses the new ...
1
vote
0answers
14 views

Can't add sub tab local tasks to admin/content/my_entity

I have a custom content entity list which has its own tab into admin/content/my_entity. The content of this tab is generated by using EntityListBuilder class. Actually, I created it with the drupal ...
1
vote
2answers
92 views

Default value for datetime field definition in content entity?

I have the following datetime field definition for my content entity: $fields['start_date'] = BaseFieldDefinition::create('datetime') ->setLabel(t('Start date')) ->setDescription(t('Start ...
0
votes
1answer
20 views

How can I make entityQuery('commerce_order') return completed orders?

Under Drupal Commerce 8.x-2.13 I find that the query Drupal::entityQuery('commerce_order') with no conditions attached returns ONLY incomplete orders (when called in the context of an API endpoint)...
0
votes
1answer
33 views

Restrict access to ECK full page, but allow embedded

Following the Lullabot article on how to embed anything in a wysiwyg with Entity Embed and friends we're using this to embed a custom entity type created with ECK (Entity Construction Kit). The ...
0
votes
1answer
37 views

How do we set required for new & optional for existing fields - when adding basic field to content type?

How do we set required for new & optional for existing fields - when adding basic field to content type? When using Drupal 8 following this how to article shows the steps to take to add a basic ...
1
vote
1answer
37 views

EntityQuery, query by referenced entity value,

I am getting an empty array when I query by the value of a referenced field. I have the following: $result = \Drupal::entityQuery('node') ->condition('type', 'custom') ->condition('status'...
4
votes
1answer
61 views

How do I add a view mode to a simple custom entity?

I have created a super-simple drupal 8 custom entity. We now need a custom view mode for this entity. What do I need to add to my definition to make my entity appear as an option on the 'Add View ...
0
votes
0answers
13 views

How to select specific entities from a view made as an REST export

I have made a REST export from a view, which is fine when I set it up to SHOW "FIELDS", which I select and define myself. My issue is if I set it up to show: "ENTITY", then I get a HUGE result set ...
-1
votes
1answer
89 views

How to add multiple values to file/image fields while creating node programmatically?

I have multiple images coming dynamically in array. But while adding those images to node only last file get attached in field and other images only saved in file directory. I have tried everything ...
0
votes
1answer
30 views

Node Reference Argument In loadByProperties() while Creating API

I have a custom module which generates an API, I want the API to filter content based on a node reference field. How do I pass the field field_author(Entity Reference from another content type) field ...
0
votes
3answers
94 views

How can I have a second alias for a node to be displayed in a different view mode? [duplicate]

I have nodes whose content type is X that I would like to render differently based on the node path. I'd like to use the default view mode for a path alias and a custom view mode for the other path ...
5
votes
1answer
494 views

Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

I have always known that loading multiple nodes at the same time is faster than loading them one by one. What I wasn't aware of, is the huge performance difference between the two ways of loading ...
1
vote
0answers
32 views

Define a default image when using image as base field in custom entity

I defined a custom entity type with an image base field. Now I want to have a default image which seems to be quite tricky: when I define a default image on a field api field and export the configs I ...
0
votes
0answers
55 views

Listing two different custom entity types in one view

We defined two entity types, questions and answers. They are related to each other but we will need a view listing all questions and answers in order of title or created date for example. When you ...
2
votes
1answer
31 views

Is there a way to get the max size of a varchar textfield?

I have an entity with a textfield created using the core Fields feature that looks like this when I inspect the type of the field table in the database varchar(40). I want to be able to determine max ...
1
vote
1answer
170 views

Can't render node view mode pro-grammatically

I try to render an HTML data from my node view mode but unfortunately, I have some small progress. I did some searching and modification on the others code Here. I have this now. $nid = 145; $...
0
votes
0answers
41 views

Updating custom entity field

I have a custom entity and wish to increase size of a varchar field. This gives helpful input: https://www.drupal.org/docs/8/api/update-api/updating-database-schema-andor-data-in-drupal-8 I added ...
1
vote
1answer
202 views

Change field label used in node display

I have a custom content type in Drupal 8.6.x. I want to be able to change the text used for a field label based on the value of a taxonomy term reference in the node. For example, I want to change ...
-2
votes
1answer
103 views

Is hook_field_group_build_pre_render_alter() deprecated?

I just came accross hook_field_group_build_pre_render_alter when I was trying to add visibility #state to a field group on the User Regsiter Form (Hide a CCK fieldgroup using #states in ...
1
vote
1answer
41 views

Get unsaved node from route parameter

What I want: In hook_media_presave I want to set a field value according to the same field on the referring node. By the referring node, I mean the node where the media entity is created through an ...
0
votes
1answer
50 views

How do I migrate content to a field added with UI to an existing custom content entity?

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

Duplicating content blocks

Is there a way to clone or make copies of blocks? For example, we have some blocks that are quite bespoke. We need to make multiple copies of them so we can display certain content within them on ...
0
votes
1answer
46 views

Store entity with entity reference field? [closed]

I want to create an ECK programmatically, I can create it but the issue is with the entity reference fields that being empty The interesting issue is that when I try to edit the created entity, just ...
1
vote
0answers
115 views

Set Default Value of User Entity Reference to logged in user

I have a Drupal 8 installation that has a user reference field and I would like the currently logged in user to be the default value for the field. I believe in Drupal 7 I would've used the [current-...
1
vote
2answers
27 views

Entity access controler not called from custom route

I define a custom entity named "Politician", where I set the class PoliticianAccessControl as an access handler. This is working fine for the canonical url of the entity set in the following way: ...
0
votes
0answers
18 views

Add a FULLTEXT index on specific column

I'm currently implementing a custom search engine in my custom module. In order to optimize my module, I would like to perform SQL queries by using the syntax MATCH....AGAINST in Entity queries. By ...
0
votes
1answer
27 views

Show Content Type Fields from a entity reference

I have a content type which i have linked to another content type. For e.g. Companies (Content Type) Employees (Content Type) When creating a new employee i have to say which company it works for so ...
0
votes
1answer
21 views

How to join the `field_data_field_*` tables with `node` table using SQL?

I apologize if I ask for something obvious, but I am asking because I could not find a simple answer anywhere. I know how to work with these tables in the PHP Drupal code, which built-in functions to ...
1
vote
0answers
81 views

After saving entity bundle, entity_get_info('node') missing 'token type' property

After saving any entity bundle, e.g. node type on admin/structure/types/manage/node-type page, node 'token type' is gone: $info = entity_get_info('node'); // isset($info['token type'])) == FALSE ...
0
votes
0answers
8 views

How do I add a reference to a parent entity when I create new subentity

I have two Entities: quiz and question. The quiz has an entity_reference field questions. I have a page /quizzes/{quiz}/questions that links to a "Add Question" page /quizzes/{quiz}/questions/add ...
0
votes
0answers
17 views

How to reference current user when creating taxonomy term

Using drupal 8.7.x I'm trying to create a vocabulary that references the user that creates the term The settings of the user reference field are the following. The taxonomy term is created using a ...
0
votes
0answers
55 views

Is it possible to make a site aware of entity schema changes that are managed externally using SQL-based storage?

Consider the following situation: A Drupal 8 site using native SQL-storage (MySQL) custom_table is added to the same MySQL host as Drupal, either as a table in the Drupal system DB or as a table in a ...
7
votes
2answers
408 views

Safe and elegant way to access nested entities via fields

I've seen a variety of approaches to access entity values in the theming layer. The code below is just a simple example using magic methods. It assumes all values are set - if any part of that returns ...
2
votes
0answers
39 views

how to update FieldStorageDefinition in a hook update?

This is a feeds module related issue. An entity update that started to cause errors on 8.7.x after the removal of automatic entity update. Originally an entity definition needed to be updated using ...
0
votes
1answer
24 views

How to get taxonomy term values?

In my user entity, I have a term reference. In that vocabulary, I have a regular field. How can I fetch that field's value? I tried the below in devel/php to no avail. $user = Drupal\user\Entity\...
0
votes
0answers
11 views

Missing is empty operator on custom entity views integration

I have a custom entity called measurement. There is a baseFieldDefinition field called completed. When I am creating a view for this custom entity, I want to add a filter to the view so that only ...
0
votes
0answers
58 views

Entity print module. How to create TOC?

I'm using entity print module and wkhtmltopdf library. Even though I've checked the create table of contents on the configuration, I don't know how to do that. I've created h1, h2 and h3 but the TOC ...
0
votes
1answer
23 views

Why is data-quickedit-entity being printed in plain text when I'm signed in?

I have a template for theming paragraph sections that, for some reason, prints out data-quickedit-entity-id="paragraph/2" in plaintext above any of my paragraphs that contain images. {% set bgcolor = ...