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
vote
0answers
15 views

Update field properties defined by hook_schema()

I'm probably a bit confused by documentation. Got a custom field with some properties defines in hook_schema() : /** * Some field type. * * @FieldType( * id = "field_selector", * label = @...
0
votes
0answers
9 views

How to change the 'target type' of an entity reference field?

I have an entity reference field that has existing data, which is populated by custom code. I now want to create a view of this data, but upon doing so have realised that the 'target type' of the ...
-2
votes
0answers
16 views

How to get multivalued reference field value in drupal 8 while using computed field [closed]

I am using computed field module in drupal 8. I have a problem getting values of a Reference field of multivalued in drupal 8. Thanks
0
votes
0answers
28 views

Configuration Import Error

I have a drupal8 in local system. I want to import my production environment configurations into my local. So i am running drush cim -y I got the following error. Unexpected error during import ...
1
vote
1answer
31 views

EntityQuery does not return values

I am trying to get some entities using the "entity.query" service. What am I doing: in my module (file "mymodule.module") I execute: function mymodule_preprocess_page(&$variables) { $query = \...
0
votes
0answers
33 views

What kind of hook_entity can be trigerred by a migration on this entity?

I have a custom content entity on which I can run a dedicated migration from csv with a form. The form is used to upload the csv file launch the migration The submit part of the form: $fileId = ...
1
vote
1answer
45 views

Error while set a paragraph field to NULL during cron run

I am using Drupal 8 and I have implemented a hook_cron to set a node field to NULL. Here is my code: if ($lesson->field_lesson_ended_at->value < $current_time && $session_id &&...
0
votes
0answers
16 views

Large amount of entity revision cleaning leads to connection abortion

I am trying to remove revisions from each entity type which has the revision feature via drush command. The amount of entities are quite a lot: around 10K nodes, 2k paragraphs. On localhost ...
0
votes
1answer
20 views

How do you reorder an entity reference revisions field during hook_node_presave?

I am trying to reorder some paragraphs based on a text field within them on node save so the author does not need to maintain the alphabetical order manually, but when I save the node all values are ...
0
votes
1answer
33 views

How to save entity from a ajax form

I'm running Drupal 8.8.x The Problem Entity is not being saved when form is submitted through AJAX. Example: Build Form public function buildForm(array $form, FormStateInterface $form_state, ...
2
votes
1answer
42 views

Errors from custom FieldItemList::getConstraints() displayed next to every single property

Summary Errors set by constraints on custom field types appear next to every single property by default. We can use the ::errorElement() method on the widget to place errors that come from the ::...
-2
votes
1answer
46 views

Understanding “entity bundle” term

I understand it is commonly assumed that Drupal terminology about "entity" is inconsistent or at least tend to be unintuititve to non-drupal-programmers. As a non Drupal programmer I have asked here ...
0
votes
2answers
61 views

How to change field attributes of Content Entity?

In a custom module, I have a content entity in which I have defined this field: $fields['formheader'] = BaseFieldDefinition::create('string') ->setLabel(t('Header')) ->setSettings([ '...
2
votes
1answer
54 views

Don't repeat yourself: Natural place for clculations on the FieldItemList of a custom FieldType wanted [closed]

I have a custom field type that contains a number field, among others. class MyFieldItem extends FieldItemBase { public static function propertyDefinitions($field_definition) { $...
1
vote
2answers
135 views

How do you enable translation for a field which was defined by a contrib module?

I am trying to enable translation for a field which was defined by a different module. The problem is this field does not list in the UI. When I checked the definition for this field in ...
0
votes
1answer
39 views

Get url of referenced entity in twig based on target_id

I have a content type with a field « referenced entity » called field_suggestion_articles. User can choose related content and a view displays this list of related content at the bottom of the ...
0
votes
2answers
149 views

What is an entity in Drupal (at least for non Drupal-programmers)?

Assuming it is possible to understand what is a Drupal entity without knowledge and experience in coding with the main program-code of Drupal 8 (PHP), or rather without understanding relevant OOP ...
2
votes
1answer
24 views

How can I check to see differences across my multisites?

Currently, we're using Acquia Content Hub to syndicate content across our sites with a spoke and wheel syndication architecture. We essentially use a single site (that content editors use to create/...
1
vote
1answer
120 views

Is a custom entity type a content type, or can both at least be logically unified?

I am having a hard time understanding the term custom entity type. If it at all matters, I understood entity type itself to be a kind of "template" for content types. I became confused after reading ...
0
votes
2answers
40 views

Is there a way to get a value of a multi value field of an entity reference (reference a field value of a referenced term)?

I hope that maybe someone had a similar use case and has an idea how to solve it: I have content type that has an entity reference field to a vocabulary. With that I would like to achieve it to not ...
-4
votes
1answer
40 views

Expected \Drupal\User\Interface got Drupal\Core\Entity\EntityInterface [closed]

I am trying to load a user and pass it a UserEvent class to simulate an event trigger. $user = \Drupal::entityTypeManager()->getStorage('user')->load($id); However, the Class only accepts ...
1
vote
1answer
30 views

Should I always save ContentEntityType after updating a value?

I have bunch of ContentEntityTypes made programatically. What weirds me out is ::save() method of ContentEntityType. In the documentation about ::save() method is information that reads: When ...
0
votes
1answer
36 views

Shipping method and shipping service from a placed order

Im trying to get the shipping method and the shipping service values after i place an order on a Drupal 8 commerce website so i can use it inside an email im sending the website's owner (not the ...
2
votes
1answer
44 views

How deal with taxonomy term parameter in multilingue site?

I have a custom controller, who take the tid parameter : /myroute/{tid} The tid is upcast with the taxonomy Term so in my controller method I have: public function index(TaxonomyTerm $tid) In this ...
0
votes
1answer
50 views

Creating a block type programmatically

I want to create a block type that has a couple of fields, a template and attached js. I want that the user in my site will be able to create blocks of this type just like they create a custom block :...
0
votes
1answer
56 views

Automatically generate product variations

I'm creating a webshop with Drupal Commerce. I have a product variation called T-shirt. It has three product attributes, color, size and print. My problem Let's say I need a T-shirt with 5 ...
0
votes
1answer
47 views

Twig template for custom entity not working

I created a custom entity called 'Representative' using the drupal console 'generate:entity:content' command. The entity works correctly I added a bundle of fields to it, added some content, and can ...
2
votes
2answers
49 views

How do I make custom entity create new revision by default?

I made a custom entity that extends RevisionableContentEntityBase. I can use the web interface to create entities. If I edit an entity and check the box Create new revision then a new revision will be ...
0
votes
0answers
42 views

Alter an Entity's field value for only one instance of the Entity on a page?

I'm trying to alter the value of a field within an Entity without it altering other instances of that entity that are being displayed on the page. I've tried hook_preprocess but I can't see how I can ...
0
votes
0answers
22 views

Unable to uninstall the Field Collection module

I want to remove field collection module in Drupal 8 as the module has been deprecated. When I try to uninstall after removing the fields from content type the option to uninstall is greyed out. I ...
0
votes
1answer
25 views

How to customise list (text) field?

On my user registration page, I would like to add a field where users can type in and select specific key words. It is possible to make such a field using webforms. It would look as below: However, ...
0
votes
2answers
39 views

Entity create access based on a custom field

Is there a way to allow/prevent users to create a new entity based on an entity field? Because the checkCreateAccess() / hook_entity_create_access() function is not receiving the actual entity as a ...
1
vote
1answer
38 views

How do I limit a normalizer to a given class or interface?

I'm creating a custom normalizer for node entities. I want to restrict the normalizer to normalize Node entities only. It seems like there are two ways this can be done: protected $...
1
vote
1answer
25 views

How can I remove the “This translation is published” checkbox?

In my custom entity module I have already defined a status checkbox to determine the entities status. What I noticed is when I enable show_revisions_ui in the annotation and have the entity setup to ...
1
vote
2answers
62 views

How to Allowed Options for BaseFieldDefinition on Custom Entity

I'm trying to access the allowed options on a custom entity's field that I created. (see code below) Is there a way to access this? One field I would like to access, for example, is... $fields['...
2
votes
2answers
62 views

Custom content entity: can't hide translation details in edit form

I've created a multi-lingual custom content entity using Drupal Console. The basic stuff with editing/viewing works fine, also multi-lingual. But for some reason, I can't hide the "Translation" ...
-2
votes
1answer
43 views

How to get all values of particular custom field of user entity using EnitityQuery?

I have added one custom field to user entity called as "customer_no". On User Registration Form, I want to check whether customer_no already exists. For that, now I want to Fetch all user's values ...
0
votes
0answers
43 views

Custom form throws 'Cannot unset string offsets' error

I'm trying to build a form for my custom entity and so far the form is looking pretty good. However, when I press the Save button I get this error: The website encountered an unexpected error. Please ...
0
votes
1answer
47 views

Set taxonomy field on node creation [closed]

I have a node type 'blog_entry' that uses a taxonomy reference (tags). The tags are created if they don't already exist, i.e. the reference field uses the option 'Create referenced entities if they ...
0
votes
0answers
19 views

When I try to load an media entity with $mid and entityTypeManager->getStorage get nothing

I'm trying to generate a field formatter, and I get this error: Error: Call to a member function getStorage() on null en Drupal\svg_url\Plugin\Field\FieldFormatter\Url4SvgFieldFormatter->...
0
votes
0answers
12 views

Getting multiple inputs with custom field

I created field for timeline and I selected unlimited for " Allowed number of values " and I "placed" this field to my custom type, After saving content I`m getting multiple instances of this field ...
-1
votes
1answer
48 views

Is it possible to get the node ID of the node that will be created?

Trying to pass some information to third party API, every time a new node is created. So far I have managed to identify the node insert/create when a node is created in hook_node_presave(). Done it ...
1
vote
0answers
27 views

Custom compound field with 2 entity_reference fields

I'm trying to create a custom compound field in D8 that, among others, includes an entity_reference to a node and an entity_reference to a taxonomy term. I did follow the answer from this question. ...
-1
votes
1answer
54 views

Custom Content Entity Bundles - How to override class methods?

I created a custom content entity type and a bundle of this entity type. The custom content entity is presented as PHP class; the entity bundle is defined in a configuration file. I created the ...
0
votes
2answers
59 views

Can I add and edit a custom entity from the same URL?

I am creating a custom entity called user_profile. Each logged in user will have a user profile. I want to be able to add and edit the user_profile entity from the same URL. The example module ...
0
votes
1answer
21 views

Entity Validator failing Integer for not being integer

I have a custom entity with an integer field with the following baseFieldDefinition: $fields['permission_level'] = BaseFieldDefinition::create('integer') ->setLabel(t("Permission Level")) ...
0
votes
1answer
24 views

How to copy/clone menu of a node when clone with Entity Clone module?

When cloning a node using Entity Clone module, the menu link are not copied. As menu link item is created and managed on the node form level, there is no reference of the menu link item in the node ...
0
votes
0answers
52 views

Get a parent Paragraph's field values from hook_preprocess_field_collection_item()?

I'm trying to update the value of a field within a Field Collection item using hook_preprocess_field_collection_item(&$variables) but the value I need to reference is in a parent Paragraph Entity. ...
0
votes
0answers
16 views

How do I retrieve the individual elements that make up an entity?

I have some entities (called media_item) that each consist of a collection of images (small, medium, large). I would like to pro grammatically select the large image path from one of these entities ...
0
votes
0answers
38 views

Type-specific fields for different categories of content type

I have a contract content type on my Drupal 8 site, and I would like to use the same content type for multiple different types of contracts. 95% of the fields are common for all types (contact ...