Skip to main content

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
2 answers
68 views

How to get the title of a referenced entity with `?_format=json`?

I have a site https://www.huytonweb.com/ the front end is in Next.js and the back end is Drupal 10 CMS. The front end will access the data from the back end using ?_format=json (like https://cms....
Dave_____1's user avatar
-1 votes
1 answer
45 views

How to duplicate the Node entity?

I want to create a word comparison dictionary. Maybe an HTML table like the following isn't good because there are too many columns for a screen responsive table. English Chinese Japanese Korean ...
user114794's user avatar
0 votes
1 answer
20 views

How to prevent the anonymous user from being the author of a custom entity type?

I am making a module that stores push notification tokens as a custom entity type. Because of the nature of push notification tokens (sending a notification to the user's device, like an email address)...
Patrick Kenny's user avatar
0 votes
1 answer
95 views

How to inject RevisionableStorageInterface()?

I have a module I'm trying to update to Drupal 11. Here's the code: public function processItem($data) { $entity_type = $this->entityTypeManager->getDefinition($data['entity_type']); $...
Patrick Kenny's user avatar
1 vote
1 answer
53 views

Two-way Entity reference, programmatically

I'm building a custom module to handle two custom entities which extend ContentEntityBase: Organization and Contact. Organization can have multiple contacts, while contact can belong to one ...
bdereta's user avatar
  • 141
0 votes
1 answer
63 views

How to get a deep clone of an entity object

Is there a way of getting a second object for an entity that is a different PHP object (with different PHP objects inside as well)? I tried using https://github.com/myclabs/DeepCopy with a node entity ...
joachim's user avatar
  • 846
1 vote
0 answers
58 views

How to make a GET request to return Entity Registration form fields?

I am using Drupal as a decoupled CMS with Entity Registration module, and would like to get the Registration Type form fields to display on my SPA. I have enabled the REST resource: /entity/...
Brownrice's user avatar
  • 111
2 votes
1 answer
65 views

How to prevent custom field being indexed in custom entity?

I'm creating custom entities extending ContentEntityBase but when I review the created table in MySQL, it has created indexes from fields I don't want. This is and excerpt of my custom entity: /** * {...
briast's user avatar
  • 654
0 votes
0 answers
22 views

Inline Editing Weight Field on admin view

I am working on a Drupal 10 site and and I have a built an admin view that has 2 fields. Node title and Weight. I would like to be able to on that view edit the weight inline on each node and save it. ...
ThankYouNeco's user avatar
1 vote
2 answers
112 views

How to quickly delete thousands of nodes?

This appears to be the prescribed way of deleting multiple node entities: $nids = \Drupal::entityQuery('node') ->accessCheck(FALSE) ->condition('field_my_field', 'something') ->execute()...
arnoldbird's user avatar
  • 1,237
0 votes
1 answer
75 views

Use token from parent entity

In a drupal 10 site I have a content type called article with an entity reference field on it called "Related nodes". Those related nodes are of type page. On the page content type there is ...
devunder's user avatar
  • 1,194
0 votes
1 answer
89 views

Get Field Weights Programmatically

I have a custom module which ultimately creates a node of a given type. It gets the fields of that node type and creates my own form with them, HOWEVER, it does not preserve that node's order of ...
Michael D. Moradzadeh's user avatar
0 votes
0 answers
37 views

Entity upload endpoint (POST) API security

Although Drupal provides default security features, I still have a doubt related to the security of uploading a file using the file entity upload API URL. If I have set the allowed file extension and ...
Tejas's user avatar
  • 1
-2 votes
1 answer
62 views

Can I display the add content form as accordion

In Drupal 10, can the add content form for a content type be set up to show groups of fields under expandable sections? We have tried to make this work with the Field Group module but the removal of ...
Bobtail3095's user avatar
0 votes
0 answers
60 views

Change Bundle Type for Media Entity

By a mistake, a lot of videos were created as documents instead of videos. I want to avoid copy them into new entities because of the usage of the existing entities. I tried something like the below ...
NicklasF's user avatar
  • 309
1 vote
1 answer
123 views

Custom entity access control handler not being called

I'm trying to define an access control handler for a custom entity, and as far as I can tell it's never being called. Here's my entity header: /** * Defines the Target entity. * * @...
Lambic's user avatar
  • 718
0 votes
1 answer
44 views

Entity reference to role

I want to add an Entity Reference field to a Group Type entity, referencing User Roles. When I add a Entity Reference > Other > Roles field, the creation/edition form of this Group Type throws ...
raistlinjoe's user avatar
0 votes
0 answers
40 views

Render array for default values in a entity reference field not loading correctly

A comment field type in a node(rendered as a form in the node view) has a user entity reference field where multiple user entities can be input and has default values set with: foreach ($...
peebs124's user avatar
0 votes
0 answers
51 views

How do I access the overridden ALT tag with the Media Library Media Modify module?

The Media Library Media Modify module ( https://www.drupal.org/project/media_library_media_modify ) allows one to override a media item's default ALT tag so you can have contextual ALT tags with every ...
Naidim's user avatar
  • 204
0 votes
1 answer
56 views

How to programmatically add the exact name of the field in the form?

I have used hook_entity_base_field_info in my custom module to add a field to the user entity: $fields['phone'] = BaseFieldDefinition::create('telephone') ->setName('phone') ->setLabel(t('...
Mahyar SBT's user avatar
0 votes
1 answer
130 views

Unable to resolve "User ID field needs to be updated" error on status page

I'm on Drupal 10.1.6, and the above-mentioned error is appearing on my status page under "Mismatched entity and/or field definitions." I had similar errors for fields on different entities (...
JOakland's user avatar
  • 462
1 vote
2 answers
200 views

How configure the field permissions of a custom entity?

I'm on D10.x.x and I've created a custom content entity - code below. Those entities are created programmatically after an event, and one is assigned to each one of the site' users. The users with ...
Giuseppe's user avatar
  • 971
0 votes
1 answer
224 views

Get the value of a custom entity field

How can I get the value of a custom field added to user profiles? I read and tested everything I found on Google, including the following code. $user = \Drupal\user\Entity\User::load(\Drupal::...
user54375's user avatar
0 votes
0 answers
59 views

Why would Manage Display break when the content type machine name is a number?

Drupal 10.1.6 PHP 8.2.5 I am not sure how long ago it started, I just noticed it about a week ago. It only happens when the machine_name of the content type is numeric. When I go to /admin/structure/...
Jamie's user avatar
  • 65
0 votes
0 answers
63 views

How can I get the error message when a user account has not been successfully saved?

I'm trying to build a rest API to provide my mobile team to register a user using mobile app. I'm using www.example.com/entity/user for rest API as POST. I'm able to create the user, but in some cases,...
veera's user avatar
  • 1
0 votes
0 answers
66 views

Is there any way to use EntityQuery on entity_reference fields in reverse?

Let's say I have two custom entity types: entity_one, entity_many. I know how to use an EntityQuery to find entity_one matches if there is a multi-value entity reference field on entity_one. $results =...
JonMcL's user avatar
  • 627
0 votes
1 answer
35 views

Prepopulating a drop-down select box that references another entity

I have a node create form for content type "space" so that the URL looks like https://.../node/add/space. In this page, there is a form with a drop-down select that corresponds to an entity ...
BMM's user avatar
  • 103
0 votes
0 answers
81 views

Query condition with entity referenced via custom field

We have the usual way to reference related tables through JOINs using: $query->condition('foo.entity:type.bar', $value); But how can this be specified when foo is not a direct field but a complex ...
Gábor's user avatar
  • 831
0 votes
3 answers
122 views

How can I have updated content entity data immediately available after update?

I created custom content entities to handle a small NGO membership (Member, Person, both linked to Drupal 'users'). I have a form allowing users to perform online membership application. Submitting ...
gbmapo's user avatar
  • 1,086
0 votes
0 answers
73 views

How to create an entity with a referenced entity [duplicate]

I work with Drupal Commerce but my question is more related to a custom entity which refers to a custom entity. Concretely, users have a profile. This profile contains fields including a field which ...
Sébastien Gicquel's user avatar
0 votes
1 answer
640 views

Query to fetch users with specific roles

I'm using the following code. $query = \Drupal::entityQuery('user'); $query->condition('uid', [302,330], 'IN') ->condition('status', 1, '=') ->condition('field_membership_status....
jg999's user avatar
  • 11
0 votes
1 answer
70 views

How can I handle race conditions in a headless setup?

I am currently trying to build an eCommerce site. The functionalities are quite basic; there are products with limited quantities and customers can purchase those products. I've decided to use Drupal ...
levente.nas's user avatar
3 votes
1 answer
127 views

Drupal::entityQuery add CASE to have NULL values displayed last

I want to sort some entities in ascending expiration date, but I want those without expiration date to be at the end. Is there a way to add a CASE expression like this to the Drupal::entityQuery? $...
user7167081's user avatar
0 votes
1 answer
96 views

How to use node context in custom block plugin to get correct revision for node and its fields?

Background information for this question can be found here: How to have a different hero image per node? I have written a custom block that takes the data from this "hero" paragraph and ...
Jordan's user avatar
  • 49
0 votes
1 answer
196 views

How to get $form_state->getUserInput() ( i.e, what the user entered in the input ) in each inline entity form and not only in the first one?

I use the Inline Entity Form module to build nested multiple forms. I have a design form in which there is an inline form - garment. And inside the garment form, there is a product field. In the ...
nathan111777's user avatar
0 votes
1 answer
83 views

Translatable custom entity

Was there any significant change in how translatable custom entities are updated leading up to Drupal 10.1? There are a few questions here that deal with the question but it no longer seems to work. ...
Gábor's user avatar
  • 831
2 votes
1 answer
91 views

How can I get the untranslated field value from a translated paragraph?

Normally you can't have different paragraph items per language so I simply want to hide selected paragraphs depending on a field value in the paragraph. I added an untranslatable list field listing ...
leymannx's user avatar
  • 18.3k
1 vote
1 answer
266 views

Hide field programmatically in "manage display"

I develop a contrib module. I added a new field to "user" entity. I need to hide this field from display in "manage display" I run this code $entity_view_display = \Drupal::...
Vanish's user avatar
  • 146
1 vote
1 answer
470 views

Can I use entityQuery() in a Drupal 10 site to query entities from a Drupal 7 database?

Can I use entityQuery() to query entities in a Drupal 7 table? I know it's possible to change the active database and then use a dynamic query to access the database, but can I do that also with ...
arnoldbird's user avatar
  • 1,237
0 votes
1 answer
137 views

Custom field type that has an array property won't save unless serialized, otherwise get "This value should be of the correct primitive type" error

I have a custom field type with two properties I am storing on it. One stores a string. The other I want to store an array. The array should be serialized in the field value table of the database, but ...
Kevin's user avatar
  • 27.9k
1 vote
1 answer
89 views

How to use bundle classes with config entities (vocabularies)?

I'd like to use bundle classes with taxonomy vocabularies. Vocabularies are bundleable config entities inheriting from EntityBase just like nodes, term and other content entities. The doc states ...
Hudri's user avatar
  • 5,539
0 votes
0 answers
27 views

How can I add custom settings for the "Rendered entity" view mode?

When using the "Rendered entity" field formatter for an entity display, there's a drop-down where you can select the view mode. Is there a way (programmatically or otherwise) to add settings ...
Geat's user avatar
  • 463
0 votes
1 answer
40 views

is it posible to get the value of other fields right inside the buildForm() method without having to save configuration?

I have a config form with two select fields. The first one(vocabulary) gets populated automatically without problems with options taken from the available vocabularies for users to pick up one. The ...
Jorge Luis Arzola's user avatar
0 votes
0 answers
100 views

403 Forbidden after 10 POSTs

Problem/Motivation Repeated posting a redhen_contact via the Drupal JSON:API succeeds for exactly 10 times in a row. The 11th attempt fails with 403 status code. After waiting for 60-120 seconds, the ...
jreinholdt's user avatar
0 votes
0 answers
53 views

Why does the Entity Comparison module throw this exception with Webform submissions?

I am using Drupal 10 with the Webform and the Entity Comparison modules. The goal of the website is allowing users to submit a product as a webform. Later, users should be able to select 2 submissions ...
Mathieu's user avatar
0 votes
0 answers
218 views

Query to order by specific item to be first and then to sort the rest with id desc

I am into a unique requirement where I need to sort records to show specific data first and then rest sort by id descending. I am able to see records using SELECT * FROM jobs where type='jobs' and ...
Tejas Damre's user avatar
2 votes
1 answer
324 views

How can I properly create separate storage for a base field?

What is the correct and supported way to create a separate table storage for a base field on a custom entity? I tried the answer here, using setCustomStorage(TRUE), but it didn't work, and I don't ...
tonytheferg's user avatar
1 vote
0 answers
110 views

equivalent of hook_field_widget_form_alter() for field formatters?

There's a hook hook_field_widget_form_alter() for altering a field widget, but I can't see anything equivalent for altering a field formatter's output.
joachim's user avatar
  • 846
1 vote
1 answer
669 views

How to use dependency injection to load node data?

In a basic Controller class, I tried to load node data using the code from this accepted answer. I.e: $nid = 1; $node_storage = $this->entityTypeManager()->getStorage('node'); $node = $...
Free Radical's user avatar
  • 15.1k
2 votes
0 answers
96 views

Convert an existing entity type to revisionable

I am trying to make an existing entity type (knowledge), from the Knowledge Project, revisionable. I followed these instructions Converting a content entity type to be revisionable. A new table, ...
Binary Alchemist's user avatar

1
2 3 4 5
175