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

How to set value for entity form date field in ajax callback

function mymodule_form_alter(&$form, FormStateInterface &$form_state, $form_id) { //print_r($form_id); if ($form_id == 'node_events_form') { $form['#prefix'] = '<div id="event-...
2
votes
1answer
42 views

How can I specify the relation type between two entities?

I am new two Drupal Trying to create two entities, Post and Category (This is for tests purposes) A Post can have one Category, and a Category can have multiple Post Here is my implementation of the ...
1
vote
0answers
15 views

How to make media description show on form view when used as entity reference

Drupal 9... I have a content type of "Resource" which uses a field "download" which references the media type "document", but when I upload a file to the field, it gives ...
0
votes
1answer
31 views

Entity reference link: add reference from Entity B to Entity A

I have created 2 Content entities. Entity A has an "Entity Reference Field" with multiple values to Entity B. This all work as expected. What I want to achieve is, to create a link from ...
-3
votes
0answers
29 views

Drupal commerce 8 Urban Hipster - Commerce 2 - Drupal 8 Demo [closed]

I am working with Drupal 8 commerce demo and have a lot of issues : Any help ? After installing Drupal commerce 8 Urban Hipster - Commerce 2 - Drupal 8 Demo at https://commerceplus.acromedia.com and ...
0
votes
0answers
30 views

How can I filter based on unique taxonomy term values?

I have a content type "book". One of its field "field_language" referencing to "language" taxonomy term. field_language can have only one value. Consider this is the ...
1
vote
1answer
108 views

How do get a value from field in if/else statement

In a custom views-view-fields.html.twig I do print a list field (field_status) without issues. The values are: new|New old|Old But if i want to do an if/else statement for printing different div ...
-2
votes
0answers
16 views

What is the url of the entity linked to a FieldItemListInterface

I am checking the code of this field-formatter-plugin especially the function that format the output of a view: /** * {@inheritdoc} */ public function viewElements(FieldItemListInterface $...
0
votes
0answers
19 views

Transform the view mode of a content type into the class of the body

I want to add the view mode of my content type as a class to body and I use Display Suite so $node['view_mode'] is not available. In MYTHEME_preprocess_html(&$variables), I injected the service \...
-2
votes
0answers
28 views

How to get node with all its fields and join references and Serialize it

System: Drupal 8 Can you point me how to fetch all fields of a node? It is better to use \Drupal::entityQuery('node') or \Drupal::service('entity_type.manager')->getStorage('node')? I tried like ...
0
votes
1answer
86 views

How to completly remove a field?

I have removed a field from a bundle (it is not used somewhere else) by using the graphical UI. But it is still listed when I run the following command (after cache clear) $this->entityFieldManager-...
2
votes
2answers
526 views

Why do setter methods in an entity return $this?

Writing a custom entity type I noticed that all setter methods in entity classes are returning $this after changes, as methods modify the object and so object will definitely being modified, then ...
2
votes
1answer
41 views

Programmatically find out field name of an Id-field

Depending on the type of entity, it is either nid/vid/uid and possibly other. It is nice to have an ->id() method which allows you to work with data in an uniform fashion without relying on those ...
0
votes
1answer
17 views

How to remove the fieldsets that are pup around "list (text)" fields that have their display set to "Check Boxes / Radio Button"?

We have a Drupal 9 website and are using "list (text)" fields whose displays are set to "Check Boxes/ Radio Button". This causes the output to be wrapped in a field set which we ...
2
votes
1answer
136 views

Unique constraint on several entity fields fails when >1 jsonapi POST requests happen right after another

In a fully decoupled drupal 9 project I have a custom entity type and added a unique constraint for several fields just as described here. This works well and adding a second entity with the same ...
1
vote
1answer
59 views

Theming a EntityListBuilder.php table using drupal/examples/content_entity_example as base

Any idea how I could to use my own custom module twig file to theme my table? I'm using drupal/examples -> content_entity_example as a starting point: in content_entity_example.module implementing ...
0
votes
1answer
55 views

How to copy fields from an entity to another for same type entities?

I have 2 entities of the same type & bundle but used in 2 different cases (linked differently to different entities). Upon publishing the second entity, I want to get the new data and put it into ...
2
votes
1answer
25 views

Number field type for specific format

I have to store number data into database in format xx-xxxxxx-xx for example I have xml data in format: ISBN="10-000000-701" ISBN="11-000000-002" ISBN="11-000000-004" and ...
2
votes
1answer
38 views

Connect field with Taxonomy Term

I have taxonomy Brand and different fields like RAM, Monitor, 'CPU' under content-type Hardware. While adding a new Hardware how can I add RAM, CPU or other fields with Brands? e.g. RAM = 16 GB, Brand ...
0
votes
1answer
24 views

Custom reference field saving empty values

I've created a custom field based on entity reference field but the target_id it saves comes from an external system. I have the field type, field widget and autocomplete element defined and working ...
0
votes
0answers
24 views

How do I add a revisions tab to a custom content entity and list revisions? [duplicate]

I'm trying to achieve exactly what's described on How to add revisions tab to a custom content entity and list revisions? I created my custom entity using Drush, and set it revisionable: Doin that, I ...
0
votes
1answer
39 views

EntityQuery condition only if field exists

How to apply a condition only if a field exists? $query = \Drupal::entityQuery('node') ->condition('type', 'videos') ->condition('field_tags', 39, '=') ->condition('status', 1) ->...
0
votes
0answers
11 views

Print a node's image-field path on the template html.twig

I need to get this tag into the header so facebook can pick it up when I share links to the website. <meta id="page-image" property="og:image" content="node-image-field-...
2
votes
0answers
14 views

How does Postgres manages case-sensitive versus case-insensitive “IN” operations in Entity Queries?

I see that an equality is converted to a LIKE operation when the field is tagged as case-insensitive, which Postgres then translates to ILIKE in the driver. However, I don’t see how Postgres is able ...
0
votes
1answer
75 views

How to remove a spurious entity update?

Something (I'm not sure what) has introduced what appears to be a spurious entity update into my Drupal 9 site. I'd like to delete the update so that I'm no longer prompted to apply it. > drush ...
0
votes
0answers
20 views

Filtering the result set of entity_autocomplete

The following snippet of code is found in the 'nodeaccess' module. At the moment, the autocomplete is allowing you to search for any user in the db. What I would like to do is only return users that ...
1
vote
1answer
13 views

Entity reference auto complete field is missing value on ajax callback

I have an entity reference field on my content type using the autocomplete widget. I'm adding an ajax callback to that field using this in a form alter: $form['field_er']['widget'][0]['target_id']['#...
0
votes
0answers
27 views

Entity reference field dependant on other entity reference field

Drupal 9. I have a content type with two entity reference fields. The first entity reference field references group entities provided by the group module. The second entity reference field references ...
1
vote
1answer
32 views

Custom Entity "changed" field is unknown

I'm having a problem I really don't know how to solve, and need your knowledge. I have a custom entity that someone created, and forgot to add the "changed" field. So the objective is to add ...
1
vote
0answers
18 views

Two step entity reference selection

I want to create a two step entity reference selection in Drupal 9. The structure so far: Content Type: Company --> Entity reference: Jobs (multiple) Content Type: Job --> Entity reference: ...
1
vote
1answer
132 views

How to hook on paragraph deletion?

I'm on D9 and I've a paragraph inside a content type node. I need to hook when the paragraph is deleted to do some custom logic and set up a queue. I've tried hook_entity_delete, hook_entity_predelete ...
0
votes
0answers
22 views

How to replace the "Views" pages of taxonomy terms?

I have a site with Drupal 9. I have created a taxonomy and I want to personalize the terms pages. In Drupal there is a "Views" for the taxonomic terms pages created by Drupal. The problem is,...
1
vote
1answer
45 views

How to display the parent taxonomy term of the "Tags" field?

On my Drupal 9 site, I created taxonomy terms in the "tags" vocabulary (the vocabulary and the default field of the "article" content type) : When I create a node, I select a ...
1
vote
0answers
28 views

Can't save value of custom datetime field

I'm reaching out because I just can't find out why my custom datetime field isn't saving its value after I submit. Context: I've created a field containing two datetime fields. I will use it to add or ...
0
votes
1answer
39 views

How get the referenced entity inside a field link?

I'm on D9. I've a paragraph with a Link field. I need to get the referenced entity programmatically. What I've managed so far is: $nid = NULL; $field_link = $paragraph->get('...
0
votes
0answers
22 views

Provide menu link when creating node programmatically and append it to parent menu link

I am creating a Node programatically: Node::create([ 'title' => "Some name", 'type' => "people", 'body' => $params['body'], 'field_people_degree' => $params['...
1
vote
0answers
28 views

How do I get the selected image style from a referenced media field?

I created a custom block with an entity reference to a media field (field_background_image). In the display settings I have chosen 'Thumbnail' as format and selected a custom image style 'background'. ...
0
votes
1answer
69 views

How to get the revision of a paragraph

I have a code which is running in hook_node_update. This code grab the revision of the saved node and compare the values of the fields between current node and its revision to generate some kind of ...
6
votes
1answer
121 views

How can I remove default image from image fields?

I need to create an image field with a default value, which must also be nullable on single content entities. Contrary to text fields or entity reference fields, I was unable to remove this default ...
2
votes
1answer
39 views

How to alter the view behind a select widget in a regular node edit form

I have an entity_reference field in a content type: field_node_ref In the field definition, it can reference all the nodes of a given type. The widget used for this field is a select widget Depending ...
0
votes
1answer
27 views

Is there a way to duplicate existing fields instead of manually creating new ones?

I am using Drupal 9 and I have a template which will require 40 text fields and 20 image fields. They are meant to display 20 individual products, so they are all similar. The display would be ...
1
vote
1answer
264 views

How can I programmatically render the summary of a textfield?

I can output a textarea field with the following code: $entity->fieldname->view(); How do I need to change that code for getting the summary of that field? (Where can I find a documentation of ...
0
votes
0answers
18 views

Deleting a Paragraph Item results in AJAX POST error "Missing bundle property on entity of type node."

Working with an older D7 site. On it, we have added the latest version of Paragraphs to add some content items to a page. This all works fine. However, when trying to remove a Paragraph Item from the ...
2
votes
0answers
44 views

How to add Rabbit Hole to a custom content entity

We use the module Rabbit Hole for nodes and terms. Now we would like to use it also for our custom content entities. I have tried to find some information, how to add the Rabbit Hole to a custom ...
0
votes
0answers
28 views

Modify the allowed options for a list field programmatically

I want to add the titles of another existing type of nodes to a select list field from another content type. I tried to do it altering the form but it gives me an error because the values added are ...
1
vote
0answers
24 views

Alter Inline Entity Form before saving

I am using the Inline Entity Form module so that I can create a content type B from content type A. I want to alter a field of content type B before saving the value. I tried to do this: function ...
0
votes
1answer
28 views

Get all entity reference options from a field name

I would like to create a node programatically and one field field_supervisors has an entity reference field for the node type People. In order to set the correct entity reference information I need to ...
0
votes
0answers
8 views

Bulk assign content to Book

I've decided to reorganize my site to use the book module. How do I bulk move specific content types to be children of a book? Bulk Update Fields doesn't include the Book meta data, so I am unable to ...
2
votes
1answer
48 views

How get the view mode\third_party_settings of a field inside hook_preprocess_image_formatter(&$variables)

I'm on D9. I've added a custom option to the image field formatter following Drupal guidelines In the preprocess of the field I can get the settings I've created: function my_module_preprocess_field(&...
0
votes
1answer
37 views

How can one programmatically get the bundle constraint for an entity reference field?

I'm working in the context of a Views plugin. I have $entity_type and $field, as required in the snippet below. How can I get the bundle constraint for the entity reference field programmatically? /** ...

1
2 3 4 5
173