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
0 answers
33 views

How can I hide a field of paragraph type?

I want to hide some fields of paragraph type. I made it hidden and visually hidden, but it still appears on the page. Does anyone have a solution for that?
Mohamed Ouhammou's user avatar
0 votes
0 answers
18 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
0 votes
1 answer
63 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
33 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
49 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
48 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
77 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
38 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
35 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
36 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
52 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
83 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
  • 452
1 vote
2 answers
103 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
  • 939
0 votes
1 answer
159 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
56 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
58 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
60 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
  • 617
0 votes
1 answer
32 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
79 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
  • 811
0 votes
3 answers
103 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,066
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
478 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
66 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
99 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
85 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
135 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
57 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
  • 811
2 votes
1 answer
58 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.1k
1 vote
1 answer
242 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
410 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,193
0 votes
1 answer
113 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.8k
1 vote
1 answer
82 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,500
0 votes
0 answers
25 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
94 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
203 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
0 votes
0 answers
70 views

Check referenced child entity update in Inline Entity Form and change author in parent entity

Can anybody help me how I can check upon entity update (with hook_entity_update or with something else) whether one of the fields of child referenced entity is update and make changes on parent entity?...
Gábor Riskó's user avatar
2 votes
1 answer
299 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
101 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
544 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
0 votes
0 answers
27 views

My product variation is not shown on the entity form

I have many products coming from a migration. This is working for most of the products, but for some of them, the /commerce/modules/product/src/Plugin/Field/FieldWidget/SingleVariationWidget.php ...
lobafox's user avatar
  • 113
2 votes
0 answers
81 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
0 votes
0 answers
39 views

Programmatically render block content render array with wrappers [duplicate]

I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this: $block = \Drupal::entityTypeManager()->getStorage('block_content') ->load($bid); $...
Jaypan's user avatar
  • 17.5k
0 votes
2 answers
287 views

Custom field Widget multiple values as a Table

Hello I created a custom field type and field widget with multiple values, one entity reference and two checkboxes. Everything's was working well, but to improve the usability of the fields, I would ...
NunesRodz's user avatar
-2 votes
1 answer
105 views

How can i subscribe/unsubscribe to a simplenews newsletter programmatically?

I have the following code to set subscriptions to a simplenews newsletter on or off: $user_load = User::load($userID_current); $newsletter_subscriptions = [ 'newsletter1' => 'on', ...
Tobi's user avatar
  • 23
0 votes
0 answers
122 views

Trying to filter the results of the entity autocomplete form element

Currently, I am working on a module that offers the function for users that belong to specific user roles to be able to write private messages to each other. In order for the sender to be able to add ...
Quetzcodecoatl's user avatar
0 votes
1 answer
26 views

How do I display the title of the entities to which the user has no access?

I created a new content type with entity references to standard pages. I am using the Taxonomy Access Control module to control the access to these pages. When users view a node of that content type, ...
Sleepster's user avatar
  • 101
1 vote
1 answer
558 views

Adding custom operations with hook_entity_operation()

I'm trying to add a custom entity operation to taxonomy terms of a specific vocabulary. I've found documentation on using hook_entity_operation() to add the operation, and that works, but I'm not sure ...
Lambic's user avatar
  • 718
2 votes
0 answers
36 views

How can I insert entity or view data into a form?

We would like to put our adoption contract online to reduce paperwork, recordkeeping, etc. In order to do so, we need to insert data from an existing entity (specifically the existing record for the ...
Ian T's user avatar
  • 21

1
2 3 4 5
175