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

ConstraintValidator fails to validate constraint on Taxonomy Term reference field

Client has a simple and consistent hierarchical taxonomy. Cities at the top level and Schools at the second level. . ├── City1 │   ├── School1 │   ├── School2 │   └── School5 └── City2 ├── School3 ...
0
votes
1answer
29 views

Where to define custom entity caching rules of detail pages

When you have a larger project you probably have both internal page cache as internal dynamic page cache module enabled. In my case I do. But I have a section on my website containing custom entities (...
-3
votes
0answers
29 views

Removing the Read more option from the main page of a content [closed]

I tried to fix this issue but I was unable to find which file to edit to fix this issue. I wanted to remove the read more option from the home page content. Please help to fix this problem in drupal 9....
1
vote
0answers
29 views

Is it possible to use a subquery in an entity query?

How can I add a condition to a Drupal 9 entity query using another entity query on a different entity type? I'll illustrate the question by describing one specific use case, though I don't think it ...
1
vote
0answers
40 views

How to query on last delta?

The documentation for QueryInterface::condition explains how to narrow a condition to a specific delta of the field being queried. Is there a way to tell the interface to look at the value for the ...
-1
votes
0answers
17 views

how can i compare data from entityreference on the mother entity

I'm trying to configurate some rules to set data value on other fields. I have an entity TEST that contain a field named field_sequence that refered to Sequence which contain other reference like Time ...
3
votes
1answer
44 views

AJAX Form using a sub-class of ContentEntityForm fires/invokes/calls the WidgetBase::massageFormValues() twice

I'm using a AJAX form. This form I build from a sub-class of ContentEntityForm. The Entity edited by this form has a field MyField. To bring all the field values in a appropriate structure I'm using ...
0
votes
1answer
31 views

Gracefully handle URL/URI/Link exceptions when using Link field formatter?

Occasionally I am encountering an error along these lines: The website encountered an unexpected error. Please try again later.InvalidArgumentException: The URI 'XYZ' is invalid. You must use a valid ...
1
vote
0answers
22 views

Auto add content to specific entity queue dependant on chosen taxonomy term

I have a People content type, which has an Expertise field which is a taxonomy term reference field. There will then be an EntityQueue set up for each Expertise term. What I'd like to do is ...
2
votes
2answers
40 views

Joining two text fields in a Computed Text field

I have two fields whose type is List (text). In the allowed values list, i want to join them. I used the following code. $value = $entity->field_a->value . $entity->field_b->value; $value =...
0
votes
0answers
57 views

Programatically reorder referenced entities by field

I have a content type Speaker that uses an Event content type as reference. The Event has a start date and time field. There can be any number of events that a speaker speaks at, when visiting the ...
1
vote
1answer
19 views

How accurate is the field list for estimating where fields are used?

I am trying to locate all places where a particular field is used. I am trying to see especially which all Views have required the field. I was planning to do a manual search using editor Find and ...
6
votes
1answer
119 views

What method should I use instead of Drupal\Core\Entity\Query\Sql\Query::addExpression()?

I am using Entity Query to select nodes of two different types. The fetching seems to be working, but I to sort the returned values. Both the content types have different date fields. I know I could ...
0
votes
0answers
24 views

How do I unset an entity reference using JSON:API?

I can't figure out how to unset an entity reference (remove a reference to a term from a node) when editing content via JSON:API. JSON to create a new node: const myNodeToPost = { data: { ...
1
vote
1answer
46 views

Update FieldStorageConfig for a field in an update hook properly?

I need to update the allowed values option on an list_integer field. For reasons at the moment, I can't just update and export the configuration and import it on production until we implement ...
0
votes
1answer
38 views

Actions form array overriding to set HTML id attribute

I extend the EntityForm class and I try to override a submission button, to set its HTML ID attribute (try #1). Since it doesn't work, I tried to wrap the button in a wrapper <div>. I tried to ...
0
votes
0answers
17 views

Display machine name in entity_form_display_edit_form

The Entity Form Display edit form has a hidden field: 'hidden_name' => [ '#type' => 'hidden', '#default_value' => $field_name, '#attributes' => [ '...
0
votes
0answers
40 views

Can't get field storage definition in custom entity

I have a custom entity 'myentity' with some fields, and one of them is a taxonomy field with the next definition: $fields['colors'] = BaseFieldDefinition::create('entity_reference') -&...
3
votes
1answer
81 views

Details wanted for "Mismatched entity and/or field definitions" message on custom field

I have developed a custom Drupal field. All works fine. We are already using the field in production for a year. But the status report for exactly this field says: Mismatched entity and/or field ...
0
votes
1answer
42 views

How can I programmatically delete a field value?

Using Entity API, I know how to get a value or to set a value : $nid = $entity->id(); $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid); ... $nom = strtoupper($node->get(...
0
votes
0answers
18 views

How do I make a custom multi-checkboxes field?

By following the tutorials and documentation I am able to create a custom field that supports a single string value. However what I'd like to accomplish is a custom list (preferably the checkboxes ...
0
votes
0answers
37 views

Multiple unnecessary joins when creating an andConditionGroup()

I have a large array of names and surnames, I need to know which of these differ from the current ones in the database. For example: $largeList = largeList(); $storage = $this->...
0
votes
2answers
53 views

How to make the float field accept decimal values?

I am using Drupal 7 and have a float field. It is used to enter prices. Most of prices I enter have decimals (e.g. 101.82, 99.88). Some of the prices are negative values (e.g. -55.52, -1009.88). ...
0
votes
0answers
18 views

Entity reference to another instance of the same type

Let's say we have a custom thing entity type, and we want to have a custom related_thing field in the entity which describes a relationship of some sort with other things. The custom field has several ...
0
votes
0answers
21 views

Hook_install or hook_modules_installed save entity does not work

I am trying to insert a new vocabulary to taxonomy because a custom entity from my custom module needs that vocabulary as an entity reference. I think it would be better to always insert the reference ...
1
vote
1answer
89 views

How can I load an entity's bundle object from a loaded entity?

If I want to get an entity's bundle object, with a node, I can do something like: $bundle_object = \Drupal::entityTypeManager() ->getStorage('node_type') ->load($node->bundle()); But ...
2
votes
0answers
46 views

How can I capture a field’s configs and storage so I can delete it and then re-create it?

I’m trying to implement this in a hook_update_N() but I’m not sure it’s proper (see excerpt below). Note I’m changing max_length in the process. What I'm trying to do: update my_custom_entity....
2
votes
1answer
32 views

Using the entity query API to identify entities with correlated values

Imagine two Drupal 9 custom entity types named a and b. Entity type a has two fields a_f1 and a_f2. Entity type b has a field b_a which is an entity reference with a target type of a and unlimited ...
1
vote
1answer
15 views

Why is <my_entity>-content-add-list.html.twig template not being used?

I have generated a custom content entity via the Drupal Console. It has bundles. I would like to customise the screen which you get to when adding a new such entity - the screen which displays the ...
1
vote
2answers
32 views

Loading content in a View via a sibling entity reference

I think what I need to do is use one Drupal View's results to filter the results of another view. Here is what I am trying to accomplish. I have 3 content types (node types): Blog, Blog Post, ...
2
votes
2answers
59 views

How to set a validation constraint for base fields like the taxonomy term name?

I'm having trouble setting a validation constraint on the name of the taxonomy term. function MYMODULE_entity_bundle_field_info_alter(&$fields, $entity_type, $bundle) { if ($entity_type->id() ...
1
vote
0answers
53 views

Save multiple entities in one transaction

We have a custom API endpoint that handles data for multiple users. Unfortunately, we are having a performance issue because every time we save a user entity, the save operation takes 3-4 seconds to ...
1
vote
1answer
55 views

How do I set the default value for a user entity reference field in hook_form_alter()?

I tried the following code, but it doesn't work. $form['field_name']['widget'][0]['target_id']['#default_value'] = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
2
votes
0answers
36 views

entityQuery returns wrong result: too many joins?

I built an entityQuery for a custom entity type "vote". I only want to get those votes for a specific poll and those by deputies who are members of a specific fraction. The fraction ...
0
votes
1answer
60 views

Optimal way to get a content type's field definition

When I need a content type's field definition in Drupal 8+, I used to run the following code (for getting 'body' field in content type 'page'): $page_fields = \Drupal::getContainer()->get('...
0
votes
1answer
28 views

Validation doesn't show an error when the value entered in the field doesn't respect the minimum length

I am using the Field validation module to validate a text field using the Length rule with a minimum length of 1. When the field is left empty, no validation error is shown. Setting the field as ...
0
votes
0answers
49 views

Chained tokens for referenced custom entities

We have two custom entities: parliament_period (can be an election or a legislature) and parliament. A parliament_period entity has a reference to a parliament entity. In a Poll node, we have an ...
0
votes
1answer
23 views

Using radio FormElement in a drupal 8 ListBuilder

I made a custom configuration entity, and I'm trying to set up radio buttons in the listBuilder. This is done in the core module language without any problems, but when I try to do the same trick with ...
0
votes
1answer
40 views

How can I remove some measure units from the Physical Fields widget?

I'm trying to alter the widget for the fields implemented by the Physical Fields module, using hook_field_widget_form_alter(). I'm trying to remove some units from the select list, but there isn't a ...
0
votes
1answer
29 views

How do I query for all the entities for which a multi value field doesn't contain a specific value?

I have a multi value field which contains plain text. This is how it looks from the edit form. I want to fetch entities that don't contain the Expired value. How can achieve it? This is the code I ...
0
votes
1answer
49 views

Base fields vs Config fields?

I have an entity and I am not sure what I should use. On the one hand, configuration fields are easier to use via the UI, why should I consider base fields? By using base fields everything is stored ...
3
votes
1answer
59 views

Add ThirdPartySettings to individual paragraphs of a certain bundle?

I want to add configuration settings to Paragraph entities in a specific bundle in Drupal 8. Theres potentially a lot of options and the need to change/update them over time, so I figure the best way ...
0
votes
1answer
121 views

Set a Data Value from Text field to Term Reference field

Node has two fields: Text field Term reference field (autocomplete?) The Text field is old and already has 500 nodes with 500 unique values. The Term reference field is new and needs to contain same ...
0
votes
1answer
92 views

FieldItemList::getValue always returns a string, even for a Boolean field

Supposed I added a custom Boolean field, whose cardinality is 1, to a content type. I create a node of that content type, enter a value for that field (for example, TRUE), and save the node. When I ...
0
votes
0answers
40 views

Cron is running but not saving entity

I am trying to create a simple hook_cron to connect with an external API, return some data and update some fields in some entities. I'm creating like this to understand better how cron works, so I ...
0
votes
0answers
55 views

How do I set an item definition class for a configuration field?

I am not able to set an item definition class for a configuration field. I tried implementing hook_entity_bundle_field_info_alter() , but it doesn't work. function hook_entity_bundle_field_info_alter(&...
1
vote
0answers
14 views

Managed file element in custom field module doesn't save target id

I have been breaking my head on this issue for a few days now. Using Drupal 9.2.x, I am building a custom field module for a client that has multiple fields. I isolated the problem by only including a ...
1
vote
1answer
22 views

Entity Browser Modal closes on Exposed Filter Submit Button

I've set up a commerce shop that uses Entity Browser to select product images. I set up a view to display the selectable images which has an exposed filter for the filename, so the user can search for ...
2
votes
1answer
28 views

Taxonomy term save very slow

I have a vocabulary with around 15k+ terms in multi-level hierarchies. Recently I noticed that with this amount of data, when I try to save a term of a higher level (parent to many), it takes a lot of ...
1
vote
1answer
106 views

How to create a custom content entity without canonical url?

I've created a custom content entity with drush generate module-content-entity, which works great. However, I want my custom entities NOT to have a canonical url. Drush automatically creates those in ...

1
2 3 4 5
172