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
0answers
19 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 ...
0
votes
0answers
12 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
25 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
13 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
24 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
31 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
0answers
22 views

Create CiviCRM Contact when creating Node “Content”

I have created a Content Type in Drupal called "Companies", when i save a new company i want a CiviCRM Contact created as a Organisation Contact Type. Is this possible using the Rules or CiviCRM ...
1
vote
1answer
31 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'...
2
votes
1answer
41 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
12 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
25 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 ...
-1
votes
0answers
23 views

How to create a custom token from the parent entity of a comment for the Message module?

I have a site with Drupal, as well as the modules "Message" and "Token". I created a custom module based on the module "Message example". It is possible to create comments on several types of ...
-1
votes
0answers
38 views

How to create a custom token for the Message module?

I have a site with Drupal, as well as the modules "Message" and "Token". I created a custom module based on the module "Message example". I created for entities, a display mode called ...
0
votes
1answer
26 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
61 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 ...
3
votes
1answer
383 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 nodes one by one. What I wasn't aware of, is the huge performance difference between the two ways of loading ...
1
vote
0answers
27 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
22 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
0answers
35 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
36 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
32 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
0answers
33 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
33 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
28 views

How can I programmatically create an entity with an entity reference field?

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
25 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
26 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
14 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
24 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
14 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
75 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
15 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
52 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
403 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
30 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
21 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
10 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
34 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
18 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 = ...
0
votes
2answers
39 views

How do I get a plaintext list of tags from a multi value entity reference field?

I have a module that's making custom RSS feeds for me. In a content type, I have my tags stored in "field_tags" entity reference field. My goal is to get the names of all the tags, and ultimately ...
0
votes
1answer
30 views

Content entity doesn't load on edit

I have a custom entity, BaseEstablishment which is an abstract base class, implemented by Practice. abstract class BaseEstablishment extends ContentEntityBase implements EntityOwnerInterface { // ...
0
votes
0answers
16 views

Setting default value to custom fields in menu items

I created a custom boolean field in my menu item using this hook_entity_base_field_info function Mymodule_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { if ($...
1
vote
1answer
41 views

Alter user's entity label method

By default the label() method of the user entity returns the username. So everywhere on the website where user references are used, the username is displayed. I need to alter this method so ...
-2
votes
2answers
39 views

How to get all the entity details which are using specific media?

I have a image "sample.jpg" (In media library) and I used this image in multiple custom blocks of different block types. Now I need the information of all the custom blocks which are using "sample....
-2
votes
1answer
24 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
83 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
66 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
22 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
27 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\...