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

How to create a new entity with default values if not passed?

Hello everyone how are you? I created a new configEntity called Modal with 3 fields: Label Body Auto Open To create a new Modal I'm using this code: $modal = \Drupal::entityTypeManager()->...
0
votes
0answers
38 views

views_embed_view in computed field

I have Content type A with these fields: Category and Amount. I want to add another field (Tax Amount) to calculate an amount based on Category and Amount inputted by user and sum of amount field of ...
0
votes
1answer
61 views

Autocomplete field where title is replaced with NID

I'm using Drupal 7 and I have made autocomplete function to be called on a field. File my_module.module: <?php function my_module_menu() { $items = array(); $items['/...
0
votes
0answers
18 views

Views entity reference field filtering results based on permissions but not overridable

I have created an entity reference field on a node type and it references entities of the Profile type, my Profile bundle is called 'Staff profile'. I want to allow certain users to see staff profiles ...
0
votes
2answers
82 views

How can I programmatically add data to an address field?

I'm trying to import user data from a json file. So far I managed to import most of the information, but now I'm stuck on the address field (created with Address module for Drupal 8). In the json file ...
2
votes
1answer
45 views

How to enable a field programmatically

I've created a field programmatically : $field_storage = FieldStorageConfig::create( array('entity_type' => 'node', 'field_name' => 'field_desc', 'type' => 'string')); $field_storage->...
0
votes
0answers
15 views

Views entity reference depending on other field in contact form

I have almost the same problem than Peter, here: Entity reference view depending on other field I have a contact form with two fields: brand and model. Brand is a taxonomy field and Model en entity ...
0
votes
0answers
16 views

Image can't be removed from widget after validation using entity validation api

I have created new media type(movie image). In that media type, I have two fields image and boolean field, I have referenced the movie image in content type and set upload limit of images to 10 and ...
0
votes
1answer
26 views

Changing existing date time field

I am working on an already existing site that has content. There is a content type with field date and time. I need to remove the time component and just be Date only without deleting any content ...
0
votes
1answer
14 views

Custom block with a field value that can be used in other twig template

I am creating a custom block with fields: field_items_to_show (items to show) field_logos (images, multiple) The site editor must have the option to set the amount of items to show in a field. in ...
1
vote
1answer
28 views

How to use Vertical Tabs on ConfigEntity Form

how are you? I've created a ConfigEntity and there a Configuration Form with Fieldsets and Fields. Example: But now I want to change this form to Vertical Tabs, like that: Do you know how can I do ...
1
vote
1answer
53 views

Drupal way of storing data related to a node [closed]

I want to store some data that is related to a node and trying to figure out the best way of doing it. For example, I send emails related to a node and I want to save details such as: To Email ...
1
vote
0answers
24 views

Guidance on entity reference - tokens or token parsing tools suggestions?

I have 3 content types - Organization, Site and Station. Stations related to a Site. Sites related to an Organization. A user can update is 'location' to show where they are working that day. I use a ...
0
votes
0answers
33 views

How translate Config Entity? [duplicate]

Hello everyone how are you? I created a ConfigEntity with some fields: Title (textfield) Body (CKEditor) After that I insert the first item: Title = "Hello World" Body = "This is a ...
1
vote
0answers
35 views

Token to output the last value in a multi-value field?

I have a text field in an Entityform set to accept an unlimited number of values: I'm trying to build a Rule that sends an email with the text from the last submitted value from the field. The token ...
1
vote
1answer
22 views

Creating a fallback field to load conditionally

So if I have a node type of Article. I have two fields on it: field_image field_secondary If field_secondary is being used, I'd like for that to be shown over field_image. Can anyone help point me ...
2
votes
2answers
67 views

Changing 2 Elements on Ajax Callback

I have an element $form['elements']['manufacturer']. On change, I want to change $form['elements']['form_factor'] and $form['elements']['model']. Currently I have: $form['elements']['manufacturer']['#...
0
votes
0answers
23 views

Better ordering of content within Books

I'm working with a Drupal site that features a fair amount of content, in excess of 1000 pages. The content is grouped in to Books and from there a hierarchical parent & child structure is created,...
0
votes
0answers
41 views

Collections of custom (ECK) entities

[ Similar question: How to add custom entities to group types? (Drupal Answers). But I ask specifically about ECK entities, not other simpler custom entities ] I want to implement collections of ...
0
votes
1answer
221 views

Update existing 'paragraph' entity while changing the ID is not supported

I'm trying to update a paragraph with this code: $entityManager = \Drupal::entityTypeManager(); $paragraph = $entityManager->getStorage('paragraph')->load('1'); $paragraph->set('...
0
votes
1answer
71 views

How to make a display mode of the current user on the home page?

I have a site built with Drupal 8 and the Twig Tweak module. I want to make the current user's frontpage_tasks display mode on my home page. How to do this ? I can make a user's frontpage_tasks ...
0
votes
1answer
10 views

Combine multivalue field rows with copy of same multvalue field

Having a list of pdfs using pdfpreview for image-preview I want to add an additional formatted text-field to this ouput. That's why I've created a copy of this field with a different formatter (e.g. ...
0
votes
0answers
23 views

Complex Group Permissions for Users and Content

My application holds content about projects. Projects have a number of entity reference fields including ones giving them both a team and a region. Projects live inside of units (1-to-1 relationship)...
0
votes
0answers
64 views

Get the value of a checkbox field (Boolean field type) from an entity object

Am trying to get the value of a Boolean field from a node entity, but it returns null whether the field is checked or not checked $field_id = 'field_test_boolean'; /** @var Node $entity */ $entity = \...
1
vote
1answer
21 views

Get order of a content type's fields

When I manage fields in content type edition I can put them in order. How could I retrieve this information to use it in a custom module. In Database there is no any column which saves weight order ...
0
votes
1answer
207 views

Create Custom Select Webform Element

I asked this last time with 'Select Other', but I am still not understanding how to change custom element's type. In this scenario, I am attempting to build a Select type webform element. I am reusing ...
-1
votes
1answer
60 views

How to automatically flag entities once (without PHP error)?

I created a custom module to automatically flag new entities and update entities. It works :-) Here is the problem : If I update a neud it is flagged. Perfect that's what I want to do, but if I update ...
0
votes
2answers
62 views

How do you target a specific type of content?

I have the content type (node), article, page, recipe. The code below can be used to flag any type of content. How do you target a specific type of content ? For example I only want to flag the ...
0
votes
0answers
27 views

how easy it is to get the date when the order is completed?

I need to get the due date (payment) of the last order, but I got some kind of crooked code. I receive all user orders by request. $allOrders = \Drupal::entityTypeManager()->getStorage('...
-2
votes
1answer
60 views

Cannot flag nodes and comments automatically

I created a code to automatically flag nodes and comments. When I put only the code to flag the nodes, it works. But when I add the code to flag the comments it doesn't work anymore. Which code should ...
0
votes
0answers
56 views

Override fieldset.html.twig

I am having some trouble understanding the concept of overriding twig templates. I have turned on debugging mode and most of the time I see overriding suggested file names like this: <!-- FILE NAME ...
0
votes
2answers
33 views

How do I limit access to a custom field type I have created so that it can only be attached to certain bundles of content?

I have a custom field class. I would like to limit it to specific content types and bundles that I will choose when my custom module is installed and as other content types meet certain criteria. I ...
0
votes
1answer
117 views

How to flag an entity when it is created or updated?

I have a Drupal 8 site with the Flag module. I want when a user creates or updates a node, product, store, group, ... the updated entity is flagged. How to flag an entity when it is created or updated ...
0
votes
0answers
39 views

Add field to menu link content

I am trying to add a list field to the menu links. I have executed the database update and it creates the field in the "menu_link_content_data" table correctly. But when I go to the menu ...
1
vote
3answers
130 views

How to clear image (or file) field data for specific node programmatically?

I need to clear/remove image (or file) field from specific node. I have before: I want to get after code execution for the field: What code should I use to properly clear image (file) field data?
0
votes
0answers
39 views

Change $form attribute in a callback

I have a form and a field model. In a hook alter, I add ajax callback to a function getMobileorFixed that does some taxonomy computation. Here is the hook_alter function THEME_form_FORM_ID_alter(&$...
0
votes
1answer
21 views

How should a custom configuration entity define a dependency on other configuration?

In a custom module I am defining a defaults Configuration entity that references a role. I would like to define a dependency on the role. This is my first attempt. public function ...
0
votes
1answer
59 views

How to use DefaultSelection::getReferenceableEntities in custom controller?

My Goal: I want to create a customized entity_autocomplete form field to better fit my needs compared to the default one - making some modifications to the HTML and JS that's being used, as well as ...
1
vote
0answers
37 views

Database dump without revisions?

Are there methods to exclude revision data in a database dump? The purpose would be to reduce the file size for developers that want a db dump for local development. I know that drush sql-dump has an ...
0
votes
1answer
29 views

Have a child node inherit taxonomy from a parent during /node/add?

In Drupal 7, I have two content types: Parent Events with tags (like "outdoors" or "popular" or "suitable for kids"). "Tags" are taxonomy terms in a vocabulary,...
0
votes
0answers
26 views

Entity Query returns incorrect results while running functional javascript test

Im writing a functional javascript test for my project where im facing a problem with my feature. I have created a group entity just above it and referencing a parent group. This doesn't work: $...
0
votes
1answer
88 views

The commerce_product.field_produit_labels field needs to be updated

almost every time I delete a field in my product types I get this message popping up in my dashboard : ENTITY/FIELD DEFINITIONS Mismatched entity and/or field definitions The following changes were ...
-1
votes
1answer
32 views

How to load ConfigEntity by Field?

I'm using ConfigEntity and on this Entity, there is a boolean Field (checkbox) called "Published". Now I want to load all Entities with field Published = 1 Do you know how I can do that? P.s....
0
votes
0answers
32 views

how to look_up a user migration with the article migration?

I migrate all the article of an old blog to drupal new website i have my image_migration : id: image label: "Migrate all media" migration_group: image_migration source: plugin: image ...
1
vote
1answer
100 views

How to add revisions tab to a custom content entity and list revisions?

I've just created/generated a custom content entity module using Drush. I've checked I would like to use revisions, but I cannot see its tab. How can I add the revisions tab to this custom content ...
1
vote
1answer
65 views

Manually removing an orphaned entity type

I have been handed an older Drupal 8 site and asked to update it to run with composer. I didn't do it in the cleanest possible way but it is working. I have run into trouble updating it. I am most of ...
0
votes
2answers
62 views

How can I change a content entity to a config entity?

I created a project using Content Entity but now I need to change this entity to Config Entity. Do you know how I can do this?
0
votes
0answers
26 views

Can I get all the possible values of a field of a content type

I've got a field on a content type that is a taxonomy reference with multiple terms. I'm trying to pull all this values from my custom module config so I can limit my module only displaying on ...
0
votes
1answer
124 views

Missing bundle entity, entity type paragraphs_type from field_instance.yml file

I'm currently trying to migrate my D7 site to D8 and one of the things migrating is field_collections to paragraphs. I have a field_collection call "field_sidebar_callouts". I want to ...
-1
votes
1answer
99 views

Get an entity reference's field values in its field template

I have an entity reference field and the template field--my-custom-entity--field-my-entity-reference.html.twig In the template I print the content. {% for item in items %} {{ item.content }} {% ...