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
0answers
16 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
73 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
26 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 ...
-1
votes
0answers
28 views

How should I read reverse-entity-relationship fields?

I have a comment type (Default comments) and a content type (Level3). The comment type has the Author, Comment, and Attachment fields. The content type has the level2_title, level2_attachment, and ...
0
votes
0answers
52 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
13 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
18 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
27 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
71 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
vote
0answers
34 views

How to filter entity_autocomplete results by content type and a field

I am trying to implement an entity autocomplete field in a form where the autocomplete entities are filtered by content type and a certain field of that content type. I know I can filter the ...
0
votes
0answers
34 views

Read comment attachment name and file location

I have a view that has comment, comment attachment(as a file). I want to read the file name and it's location. View looks like below: I am able to read the title by the below code: public function ...
2
votes
0answers
44 views

Create several fields from one array field

I have a Drupal View based on one entity that is pulled from another database (it is a CiviCRM entity pulled into Drupal with the help of CiviCRM Entity Drupal module). One of the fields I use is an ...
1
vote
0answers
41 views

Read view row entities and create a node for each entity

I have a view that looks like in the following screenshot. I am creating a custom action to publish selected comments and create a node for each comment. The custom action code is the following. ...
0
votes
1answer
21 views

Set the menu link description in hook_entity_presave()

How do I update the menu link description with hook_ENTITY_TYPE_presave()? I can print out the menu link title and menu link description with the following code. kint($entity->menu['title']); ...
1
vote
2answers
26 views

How do I automatically fill the subject in the contact forms?

I created 2 types of contact form. I disabled Subject in Manage form. I want the fake Subject field not to be displayed in the contact form, and I want it to be filled in automatically. How do I ...
1
vote
1answer
32 views

Programatically create paragraphs entity form

I am in a situation where I would like to split out Paragraph entities to separate forms. Edit forms are no problem: $entity = Paragraph::load($entity_id); return \Drupal::service('entity.form_builder'...
1
vote
1answer
38 views

Optimize fetching data from entity objects [duplicate]

Currently we are using EntityTypeManager to either load or loadMultiple : $this->entityTypeManager->getStorage('node')->loadMultiple($nids); $this->entityTypeManager->getStorage('node')-...
1
vote
1answer
41 views

How to load a file entity by uuid?

So I am trying to use the default image for users in a menu block if a custom one does not exist. And for it I am getting the image file uuid: $default_image = $user->get('user_picture')->...
0
votes
0answers
20 views

How to use [node:title] token as filename for media type fields?

I have a Drupal 9 site have two modules FILE (FIELD) PATH module and token is used. So for a content type, one image field is there where in the File (Field) Path settings I have the file name as [...
2
votes
1answer
43 views

Validation on custom entity edit form

I have a custom entity where, instead of using the usual way of specifying edit form options with setDisplayOptions('form' and relying on ContentEntityForm to create my edit form for me, I have to ...
1
vote
0answers
27 views

How can I avoid double line breaks (<br><br>) in a text field (field type: text unformatted long)?

How can I avoid double line breaks (<br><br>) in a text field (field type: text unformatted, long)? Users write text into this text field. When they hit Enter twice, the result is: <br&...
1
vote
0answers
30 views

A new field doesn't show on the page

I recovered a site from a backup which had run on Drupal 7.7. I upgraded it to Drupal 7.80 on another instance. Now, we need to add new fields to content types and add new nodes. I added a field as an ...
0
votes
1answer
16 views

Access a user entity reference in a commerce-product template file

I have a field_intervenantfield which contains a user entity reference. In the commerce-product template file, I want to access the description field of each intervenant. How can I achieve it? I tried ...
0
votes
0answers
19 views

How to get a product variant field (not attribute) value?

I have created a product variant with 1 attribute (say "Subscription Plan" or attribute_sub_plan) and 1 field (say "Number of Issues" or field_num_issues). The attribute was for ...
1
vote
1answer
33 views

Problem removing field collection module

We recently migrated successfully in our drupal 8 instance from field collection module (latest alpha) to paragraphs. Now I am trying to remove the field collection module from our drupal instance, ...
-1
votes
1answer
34 views

Rules Custom Field

I am developing a Drupal site, where the administrator creates user accounts. Indeed for this site the administrator creates user accounts, he fills in the fields with the strict minimum (Last name, ...
0
votes
0answers
14 views

How to change form-text field maxlength / Translatation field?

I would like to increase maxlength of translation field. In database, field is VARCHAR (255) For translation version : maxlength = 128 I dont'know how to change maxlength for translation version. Is ...
0
votes
0answers
40 views

Error with creating custom fieldtype

I am creating a custom multi-value fieldtype for some functionality that I need. I have been using the drupal core 'telephone' module and the contrib 'address' module as reference, but am running into ...
1
vote
2answers
29 views

How to handle appendItem() when a list is full?

I'm creating a custom JSON:API Resource to store push notifications tokens. The user account field where the tokens are stored has a limit of 5 items. I am using appendItem() to add the value to field....
1
vote
1answer
35 views

Why put a different machine name for the same field?

I have an image field for my article content type with the machine name field_image I created a new type of content for cooking recipes. Should I use the existing image control or create an image ...
0
votes
0answers
19 views

Field difference plugin for referenced entities

We have a way to see diff for field changes/revision on paragraphs hosted on any entity, however does not look like we have similar functionality for Referenced Media Entities. Paragraph module seems ...
0
votes
0answers
20 views

Custom Submit Button On Inline Entity Form Triggers Gives Wrong Triggering Element

I have implemented hook_field_widget_form_alter() to add a new #process array item. E.g. hook_field_widget_form_alter() { $element['#process'][] = ['custom_process_function']; } This part works ...
1
vote
1answer
69 views

How do I customize an entity's canonical page? [closed]

I have an entity called SyncJob and it contains the following fields: id progress: integer total: integer I need to customize its view page (canonical, not the collections one) to show the following ...
1
vote
0answers
29 views

How do I make an existing custom entity fieldable? [duplicate]

I have a custom entity that isn't showing the ability to add fields. I need to add a field to it, and I want to do it through the UI. The entity was created in a custom module, which I can modify. How ...
0
votes
1answer
90 views

How do I add fields to an existing custom entity? [closed]

I have a custom entity that fieldable. I need to add a field to it, and I want to do it through the UI. The entity was created in a custom module, which I can modify. How can I make the entity ...
0
votes
0answers
47 views

How do I alter a bundle and programmatically add a form with a custom form mode?

I have created a custom entity type called custom_enitity and new bundle scores, using UI. Also got custom form display called score to add score via custom route. I keep getting the following error ...
0
votes
1answer
24 views

Allow to filter (in a view) on a datetime field of a custom entity

I have created a custom entity as follow: Here is an extract of my entity definition in modules/custom/bank_operation/src/Entity/BankOperation.php Notes: 1- As you can see, I have changed the value ...
0
votes
0answers
33 views

How to use one of the 2 context filters in a view (with an OR)? [duplicate]

I have a view with 2 relations with the store for 2 different entities. I want to filter the view with the store id for the 2 relationships. I created 2 context filters in the views. You must use the ...
3
votes
1answer
47 views

What's the difference between indexed and non-indexed field in Views and Search API?

I'm using Search API with a database backend and Views to build the search results page. More specifically, I'm using fields in Views. When selecting fields, I see two options for example: Title ...
3
votes
1answer
111 views

How can i add a property(uuid) to existing custom entity base_table?

I want to add uuid property to existing custom entity extending ContentEntityBase. I've tried to a add the uuid entity key and installed field storage definition by: function ...
0
votes
1answer
48 views

Body text special characters are escaped

I have this code which I am using to get the body text from a node rewrite it with a regular expression and replace it, (I am replacing all you tube video links with embed codes) function ...
0
votes
1answer
13 views

IF statement to check if loaded entity is of type

In my module (fork of ECK Clone) I'm trying to set a default value when an entity of type "Course" is cloned. Currently I do: function eck_clone_clone_entity($entity, $account = FALSE) { $...
0
votes
1answer
13 views

Create a view of the first entityreferenced child item from a multifield for a list of parent nodes

I have a node type A containing a multifield of entityreferences to another node type B and using only the views admin interface I want to create a list of the first type B child entityreference on ...
0
votes
1answer
57 views

Newly created field not being added to entity

I have created a form that adds a subset of field types to an entity (does not support bundles). (the reason for the custom form is that end users find the Drupal standard 'Manage fields' workflow ...
0
votes
1answer
20 views

Exract all node field values to json including reference entities with value

I am writing a module to export drupal's content to another platform, the module provides a UI to manage content types and their fields to be shared on another platform via API. So far i have managed ...
0
votes
2answers
153 views

OO way of adding base field definitions

Is there any object oriented Drupal way to add a base field definition to an existing entity? Of course I am familiar with hook_entity_base_field_info(), but I am trying to keep my .module file size ...
0
votes
1answer
50 views

How to use “content entity” type in a View?

I have used the "content entity example" coming from the example project. This example module/: defines a "Contact" entity; it can have extra fields, displays can be configured (...
-3
votes
1answer
95 views

Undefined function 'entity_metadata_wrapper'

A custom module is using the following code. function sun_blogs_views_pre_render(&$view) { //...... $wrapper = entity_metadata_wrapper('node', $node); $title = $wrapper->...
0
votes
0answers
38 views

Programmatically add field automatically to all new bundles [duplicate]

I have a module with a bundleable content entity that has been deployed to an existing site. On the site, a bundle was created and a date field was manually added to it via the UI. Now the date field ...
0
votes
0answers
56 views

How can I create a view of different entity types with common sorting?

Both, profiles and nodes (of one spec. nodetype) have the same taxonomy attached. (Using the profile module). How to create a view of both together, profiles and nodes (of this type) to show as a ...

1
2 3 4 5
172