The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
2
votes
2answers
3k views

How do you programmatically delete a field?

I found this page: https://www.drupal.org/node/2012896 which lists this: // Deleting field storage. FieldStorageConfig::loadByName('entity_type', 'field_name')->delete(); // Deleting field. ...
0
votes
1answer
537 views

commerce_customer_address

I am using Commerce Kirckstart installation. I would like to change a field in commerce_customer_address. I only want a new field, like telephone and I would like to remove State. Some one knows how ...
0
votes
1answer
536 views

I need to reference a custom field I created in User Profile

I used Drupal 7 computed fields to calculate weight loss. This is what I current have. Which works in a sense but only where the user inputs their initial weight and subtracts their current weight to ...
0
votes
3answers
415 views

How to get a list of Users as values for a select list field?

How do I get a list of users of a specified role to populate a select list in node/add/* ? For example when creating a piece of content I want a field "Select Your Moderator of Choice" and the ...
2
votes
1answer
621 views

How to check in a rule if the data from a field collection has changed?

I want to add a rule (using the Rules module) for printing a message after changing a field in a field collection. The field collection consists of the following three fields: Reference to Version (...
3
votes
1answer
122 views

Difference between $bundle and bundle()

Background information: I'm trying to manipulate the available options of a list type text field, depending on the host bundle: function wtbase_options_list_alter(array &$options, array $context) ...
0
votes
1answer
16 views

Create a view to list all contents that uses media through any entity reference field

I know it is possible to create view to list all content that is using media through a particular entity reference field. Is it possible to create a view to to list all content that is using media ...
1
vote
1answer
369 views

How to submit a field collection from a form into a created node

I would really appreciate if somebody could help me with this :) I have a field collection called field_formations. Inside it I have 2 fields: field_technologies - (reference to a taxonomy). ...
1
vote
1answer
3k views

Create a field collection field programmatically

Is there a way to create a field collection programmatically? I saw this code: $field_collection_item = entity_create('field_collection_item', array('field_name' =>'field_text')); // Create new ...
0
votes
1answer
15 views

Entity without translation

I want to make entity in Drupal 8 called cash that store only numeric value (integer or float). I think, that entity not need translation. Is it possible for us to create custom entity without ...
1
vote
2answers
5k views

Get the uri/path value of an image in the field template

I have created a custom field template for an image - field--field_images.tpl.php with the following code: <?php $url = file_create_url($field_images['uri']); $url = parse_url($url); $imglink = ...
1
vote
1answer
579 views

How to render / preprocess list of entity reference nodes?

I hove a content type that editors can 'attach' related nodes to. When I 'theme' / 'style' nodes of this content type through view mode everything is basically fine: the related nodes are rendered ...
0
votes
1answer
654 views

How to download the files data attached to webform

I have webform with text fields and file upload field. How can i download the all the documents which was uploaded through this webform.
3
votes
3answers
465 views

Suitable way to hide a paragraph entity

I have read Hide an entity with hook_entity_view_alter(), and by all rights this code should hide every paragraph on a page: /** * Implements hook_ENTITY_TYPE_view_alter(). */ function ...
5
votes
3answers
4k views

How do I iterate over values of a multivalued field with entity_metadata_wrapper?

For instance, I have a taxonomy_term_reference field with cardinality -1. If one or more terms are selected, I can use this code: foreach ($wrapper->field_myterms as $t) { $terms[] = $t->...
0
votes
1answer
707 views

Add classes to programmatically added fields

I have programmatically created a few content types and fields for said content types in a module I'm building, but I need to add classes to said fields. So if I have a text field called "...
1
vote
1answer
674 views

How can I make a template for a product type in Commerce?

I want to be able to write my own markup for the fields (see image below) of each product type – how do I do this? My main reason for this is that I want to group them with my own HTML rather than the ...
0
votes
3answers
1k views

How do I perform outstanding entity updates after 8.7?

I have just tested the update to 8.7.1 (from 8.6.x) which includes the removal of the old automatic entity update functionality, which means drush entup no longer works. As far as I understand the ...
1
vote
3answers
1k views

How do I update a user profile with entity_metadata_wrapper()?

I got an error while updating user profile data such as name,password and email. I am using entity_metadata_wrapper() for processing update. exception 'EntityMetadataWrapperException' with message '...
0
votes
0answers
13 views

Items removed from Node Reference field are still displaying on the node

This problem only very recently cropped up; I've never encountered it before. I have a content type (Resource) that contains a Node Reference field (pointing to Organization nodes) that allows ...
1
vote
1answer
2k views

How to print the file description to my twig template?

I'm trying to figure how I can obtain or print the file description that is uploaded on my node and display on my twig template So far I have tried {{ file.entity.label }} which only prints the name ...
1
vote
1answer
567 views

How to create a confirm popup when delete item with field collection?

I have configured a field collection field (unlimited items) for a content type and I want create a confirm popup when user delete an item. For this, i found that i can directly go and modify 2 ...
0
votes
1answer
363 views

“Image Upload Button” section remove after click on upload

I am trying to edit users's profile page in Drupal 7. I have an image upload button there, but it remove (hide) after click on upload button . But If i login with admin its working fine, means image ...
0
votes
1answer
92 views

Where 'target_id' of field_data_field… tables points?

I'm extracting database information from a Drupal site that I have using SQL queries. I have seen that, in the field_data_field... tables can be three type of information storage: field...value: ...
0
votes
0answers
20 views

Revisions Tab is not visible

I updated Drupal to 8.6.16 version and after that Revisions Tab is disappeared. Actually, all revisions are saved fine and I can see them because I have access to the page "xxx/revisions", but I don't ...
0
votes
1answer
566 views

How to show an Inline Entity Form on a PM page or panel?

I'm trying to include an Inline Entity Form on a panels display (via ctools Page Manager). The Inline Entity Form field is attached to users, and the page in question has the user's context. The ...
0
votes
1answer
599 views

Getting a custom field to appear correctly in Rules using entity form module

I have written a custom field widget called foo which is inserted into an entity form to provide an autocomplete to another web service. I am trying to get the field data to be sent in an email via ...
9
votes
1answer
3k views

Load a file entity by URI

Is there a way to load a file by URI in Drupal 8? In Drupal 7 it is possible by the next example: $uri = 'public://file.xyz'; // Take a look at: file.inc::file_load_multiple $files = ...
4
votes
2answers
6k views

How can I load a File entity?

I want to find out whether a physical file is managed by Drupal and if it is, then load it. I'm having trouble with the documentation which keeps displaying "File not found" at crucial moments, but ...
1
vote
2answers
631 views

Hide Alt and Title for image field

How to hide Alt and Title fields for anonymus users when they upload images? I use tokens for these field that's why I need to hide them.
1
vote
0answers
14 views

How to mark related entities as dirty in search api module when edited?

I am using Drupal 7 with the search api. I understand that one of the 'common pitfalls' of the search api is 'Changes in related entities don't lead to re-indexing'. I am bringing in a field called '...
0
votes
0answers
12 views

Entity Translate won't show translations on template overrides

I have set up entity translate and it lets me add the translations so they are stored in the DB. But when I click on the translated page, all I see is the orginal language which is English. So I these ...
0
votes
1answer
52 views

Custom remote video thumbnail

I'm using the media entity from Drupal core together with the media library, to handle media on my site. I have Remote Video and Image with crop media types. I'm using the crop and image_widget_crop ...
0
votes
1answer
28 views

Entity Validation API: Retrieve parent field entity while validating

I'm using the Drupal 8 Entity Validation API. I've implemented my Constraint and ConstraintValidator classes and added them as a constraint against the relevant entity field. If I understand the ...
2
votes
1answer
1k views

Migrate row data into drupal text formatted long multiple

I would like to import 3 different row values into a multiple text formatted long field. This is my migrate (plus) map yml: ... field_mytext_formmated: plugin: get source: - ...
1
vote
1answer
611 views

dynamically populate a select field based on the selection in another field works only the first time

I am trying to dynamically populate a select field (chamiponship) based on the selection in another field (country). It works fine when I load the page but just the first time, the second time I ...
0
votes
2answers
570 views

Embed a node add form on a parent node

I have a product display node and I'm trying to add a rental form to the node so that anyone can submit a rental form and have that reference the node. I was thinking of making the rental form a new ...
0
votes
1answer
614 views

What is the best way to add a confirmation tooltip to the remove button of a managed_file field?

Another Update I'm trying to implement the solution found here: Intercept click event on a button, ask for confirmation, then proceed, but the remove button still submits normally. I know my JS is ...
0
votes
2answers
2k views

Field Collection fields not displaying

I have been running into some trouble with displaying Field Collections. I have a content type (products) that has a field collection called packages. Randomly I would notice that sometimes the field ...
2
votes
1answer
830 views

How to expose filter for entity reference as dropdown in the Search API view?

In my Search API view, I'd like an Exposed filter > Entity reference to be a select box, not a text field. Details I have a view which I created like: Views > Add new view > Show: default node ...
1
vote
1answer
585 views

Adding conditional statements as Math expression to custom text fields in views

I have created views in which i have added custom text and Math expression. I displayed view in table format I created one Math expression which is noticed below: [Field 1] - [Field 2] I have ...
1
vote
2answers
992 views

How do I render form fields in my custom.tpl.php template?

Here's my dilemma, I built a custom form-based module that allows a user to vote on a future conference location but I'm having a issue printing or rendering my form fields to have them display in my ...
16
votes
3answers
14k views

Get all fields defined in a bundle

to get all fields used in a content type, in Drupal 7 I use the following code. $fields = field_info_instances('node', 'article'); What is the equivalent for Drupal 8?
0
votes
1answer
348 views

Field collection item not visible to anonymous user

I have a field collection, 'related content', that displays inside the 'page' content type tpl. It is a 'field' in the page content type. It works perfectly fine while logged in as admin, but cannot ...
0
votes
1answer
648 views

Simple webform with payment module

what I need do is not an ecommerce site. On my drupal website I need a simple web form with a payment (by paypal) and a node reference field prepopulated (by the entity refence and entity reference ...
1
vote
1answer
2k views

Entity metadata wrapper + entity reference + translation

I have two node types: 'festival', which can be translated and 'event', which untranslatable. Event has multivalued field reference to Festival, so that one Event referenced to all translated festival ...
2
votes
2answers
459 views

Displaying all values of a List (text) field, whether checked or unchecked

[Drupal 8] I have a List (text) field that allows multiple values, displayed as a check box list when editing. But when viewing the node, only the checked values are displayed. How can I display all ...
0
votes
1answer
399 views

How to get the actual value of a field in Views?

I'm using the Views module and Drupal 7 and want to add a class to all rows of my table that have a certain value for a certain field. The field is a bit field and is included in my query. I have ...
1
vote
1answer
19 views

Default all entities to English

At some point we will be enabling translations on all entities in Drupal 8. However, we are not ready yet so in the meantime we would like to set all of the entities (content types, taxonomy terms, ...
2
votes
2answers
635 views

Lock a Field Instance

Is there a way to lock a field instance? I want to prevent users from editing or deleting a given instance, but allow the field to be customizable elsewhere by the user. If I lock the field, it will ...