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
1
vote
1answer
28 views

Difference between $bundle and bundle()

Background information: I'm trying to manipulate the available options of a list type text field, depending on the host bundle: function wtbase_options_list_alter(array &$options, array $context) ...
0
votes
1answer
13 views

Create a view to list all contents that uses media through any entity reference field

I know it is possible to create view to list all content that is using media through a particular entity reference field. Is it possible to create a view to to list all content that is using media ...
0
votes
1answer
15 views

Entity without translation

I want to make entity in Drupal 8 called cash that store only numeric value (integer or float). I think, that entity not need translation. Is it possible for us to create custom entity without ...
0
votes
0answers
10 views

Items removed from Node Reference field are still displaying on the node

This problem only very recently cropped up; I've never encountered it before. I have a content type (Resource) that contains a Node Reference field (pointing to Organization nodes) that allows ...
0
votes
0answers
19 views

Revisions Tab is not visible

I updated Drupal to 8.6.16 version and after that Revisions Tab is disappeared. Actually, all revisions are saved fine and I can see them because I have access to the page "xxx/revisions", but I don't ...
1
vote
0answers
12 views

How to mark related entities as dirty in search api module when edited?

I am using Drupal 7 with the search api. I understand that one of the 'common pitfalls' of the search api is 'Changes in related entities don't lead to re-indexing'. I am bringing in a field called '...
0
votes
0answers
10 views

Entity Translate won't show translations on template overrides

I have set up entity translate and it lets me add the translations so they are stored in the DB. But when I click on the translated page, all I see is the orginal language which is English. So I these ...
0
votes
1answer
26 views

Entity Validation API: Retrieve parent field entity while validating

I'm using the Drupal 8 Entity Validation API. I've implemented my Constraint and ConstraintValidator classes and added them as a constraint against the relevant entity field. If I understand the ...
1
vote
1answer
16 views

Default all entities to English

At some point we will be enabling translations on all entities in Drupal 8. However, we are not ready yet so in the meantime we would like to set all of the entities (content types, taxonomy terms, ...
0
votes
1answer
44 views

Custom remote video thumbnail

I'm using the media entity from Drupal core together with the media library, to handle media on my site. I have Remote Video and Image with crop media types. I'm using the crop and image_widget_crop ...
2
votes
1answer
77 views

How to add a theme preprocess function for published state?

I want to create a body class for the published state of a node. I found some suggestions below for Drupal 7, but this code is not working for my Drupal 8 theme. Add class based on published state ...
0
votes
1answer
22 views

Referencing “type” in nodes returned by loadMultiple();

I know there are easier ways to sort nodes by type, using views, or using: $query->loadByProperties(['type' => 'my_content_type']); ... but what I really want to do is return ALL nodes and ...
0
votes
1answer
19 views

How can I filter which entities are available in the admin form for an Entity Reference Field? [duplicate]

I've got a Field which is called "Primary Article" which is an Entity Reference Field. I've configured this field setting the "Reference Type" to be "article", so that only articles show up in the ...
2
votes
1answer
34 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
9 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
19 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
25 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
42 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
26 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 ...
-1
votes
0answers
6 views

How to make the overviewTable to be descending

I want to have an overview table with descending id's. It feels like i looked everywhere for the answer but it just feels like nobody cares.
0
votes
1answer
21 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
23 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
43 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
31 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
17 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
27 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
34 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
36 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'...
3
votes
1answer
47 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
32 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
29 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
69 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
464 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
31 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
25 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
30 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 ...
0
votes
1answer
108 views

Can't render node view mode programmatically

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
36 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 ...
-2
votes
1answer
51 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
38 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
43 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
34 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
36 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
45 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: ...