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
0 votes
0 answers
49 views

Drupal 10 - Get the value of a custom user field

i spent my day on that... how to, in Drupal 10, get the value of a custom field added in the user profile. i read and test everything found on google, just like that (from different thread/forum): $...
user54375's user avatar
0 votes
0 answers
48 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
-3 votes
1 answer
79 views

How to programmatically create a redirect and then get the redirect ID of newly created redirect? [closed]

I am trying to create a redirect programmatically, then reference the ID of that redirect from a node. I use hook node in my module with the following code to create a redirect. use Drupal\redirect\...
Jay Williams's user avatar
0 votes
0 answers
56 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
33 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
21 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
69 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
  • 801
0 votes
3 answers
82 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
72 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
220 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
53 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
70 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
61 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
  • 27
0 votes
1 answer
66 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 ...
ewik's user avatar
  • 15
0 votes
1 answer
38 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
  • 801
2 votes
1 answer
38 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
  • 17.8k
1 vote
1 answer
165 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
  • 166
1 vote
1 answer
187 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,079
0 votes
1 answer
66 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.7k
1 vote
1 answer
69 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,286
0 votes
0 answers
17 views

How do I add cusom settings for the "Rendered entity" view mode?

When using the "Rendered entity" field formatter for an entity display, there's a dropdown 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
68 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
47 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
117 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
58 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
239 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
81 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
298 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
22 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
  • 103
2 votes
0 answers
59 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.3k
0 votes
2 answers
162 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
76 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
80 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
20 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
0 votes
0 answers
20 views

How can I add workbench_access to a custom content entity?

I have a custom entity and want to use our current workbench_access scheme to it. I've google for a long time and can't find and example. This article says that workbench_access now supports multiple ...
johnfallen's user avatar
1 vote
1 answer
307 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
  • 708
0 votes
0 answers
26 views

Check if a value has changed [duplicate]

Is it possible to check within a constraint validation if a field value has changed? namespace Drupal\example\Plugin\Validation\Constraint; use Drupal\Core\Entity\EntityPublishedInterface; use ...
Sebastian's user avatar
  • 635
2 votes
0 answers
34 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 vote
1 answer
101 views

How can we limit the end date selection to +90 days from now on core Date Range widget? [closed]

We're using Drupal 9's core Date Range module and need to limit the end date selection to no more than 90 days from today. I've searched far and wide and have not come up with a workable solution. ...
quantumized's user avatar
  • 1,177
0 votes
0 answers
300 views

Entity Print - Getting error while clicking on View PDF

I am using Entity Print module and I didn't change its default configs. I am using Dompdf library for generating PDF on node. I have enabled View PDF from Manage Display page. When I am clicking on ...
Pankaj Sachdeva's user avatar
0 votes
0 answers
49 views

How to make an entity reference field only load a rendered entity, when clicking on it? (ajax load on click)

I want to mimic a zettelkasten system, by starting in a very simple way: An entity of type 'Note' includes a body and an entity reference field, that can reference another note (of the same entity ...
Yuri's user avatar
  • 618
0 votes
0 answers
60 views

How to limit the depth of embedded referenced entities

Using Drupal 9 or 10 Using a node type Page with one entity reference field, which is displayed as rendered entity, displaying the same Page content type. When viewing a page, how do I prevent the ...
Yuri's user avatar
  • 618
0 votes
0 answers
125 views

Why the form does not save data from the entity reference field?

I have a custom entity (with the name Entity Quote), from the add form of this entity I make a multistep form. In the custom entity Entity Quote, I added another custom entity (with the name Quote ...
tim's user avatar
  • 9
1 vote
1 answer
86 views

Can we export json schemas for type script usage?

We have a Drupal installation that acts as a backend and a front end that uses the HttpClientModule from Angular to query this data. Thanks to the typescript base, we can provide the functions of this ...
flauschi's user avatar
1 vote
1 answer
60 views

Is there a way to specify order in a search_api query manually given a set of node ids?

Using search_api I have an query with the following condition $query->condition('nid', [1,5,3,7,10], 'IN') I know I can sort by things like created date or title, but what if I knew the exact ...
Amy's user avatar
  • 5,632
5 votes
0 answers
245 views

Add third party settings to a basefield definition

Is there a way to add third party settings when defining a basefield for a custom Content Entity? I am creating a new Entity type and want to keep the fields defined in code vs config as much as I can....
Jimmyb_1991's user avatar
1 vote
1 answer
198 views

Correct schema for an Entity Reference in config settings

Background I am creating a schema for a custom module's config settings, which are saved from a simple settings form. It has some basic fields, such as a checkbox for a Boolean value for hiding some ...
mbomb007's user avatar
  • 516
2 votes
0 answers
192 views

Why doesn't the entity access handler I wrote work when the entity is referenced?

I have set a handler for the access of my entity but when I reference it in another entity, the access is not checked. I want the reference and the entity to have the same access check. Any idea ? The ...
CWolf18's user avatar
  • 21

1
2 3 4 5
175