Questions tagged [entities]
Nodes, comments, taxonomy terms, and users, in the terminology used since Drupal 7, are generally called "entities."
2,352
questions with no upvoted or accepted answers
8
votes
1
answer
3k
views
Add Expression for Entity Query
I've been working with the entityQuery to query the db and get an array of filtered nids however I need to add an expression to my query.
I've checked the Query class and found a protected sqlQuery ...
6
votes
0
answers
288
views
How to get referencing parent entity when adding entities via Inline Entity Form to set automatic titles?
I have a content type "Parent" and a content type "Child". When adding Parents, the user can add Childs via Inline Entity Form.
Child content types have Automatic Entity Label enabled. In that ...
6
votes
1
answer
158
views
Benefit of config entities over regular config entries?
In Drupal 8 it is possible to store configuration in "config entities".
However, the same can also be achieved with non-entity config entries.
E.g. one example for a config entity schema, from core....
6
votes
0
answers
112
views
How to modify auto populate field value?
I m Stuck in two situation where I have to modify value of one field depending on another field selection.
First situation is like I have two field
Region (Node reference) - the widget type is ...
6
votes
3
answers
3k
views
How do I define a computed field equal to the concatenation of two fields of my custom entity?
I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, userID, created, changed. I created it with baseFieldDefinitions.
I want to have a computed field ...
5
votes
0
answers
242
views
Add third party settings to a basefield definition
Is there a way to add third party settings when defining a basefield for a custom Content Entity?
I am creating a new Entity type and want to keep the fields defined in code vs config as much as I can....
5
votes
0
answers
454
views
How best to determine what differs between field schema and field definitions when "Mismatched entity and/or field definitions" is reported?
I've inherited a large, enterprise Drupal 8 site in which we have many "Mismatched entity and/or field definitions" warnings reported in the status report. The site is currently running on ...
5
votes
0
answers
524
views
How to add translation to Inline Entity Form + Entity Browser
Situation
I've got a special "Dashboard" node that consists of entity references to other node types. In dashboard form mode all widgets are configured to use Entity Browser to display an (Inline ...
5
votes
2
answers
992
views
How to create field collection item fields programmatically?
I'm trying to program a field collection with field collection item fields like the code as given by rbruhn on Creating field collection programatically. I want to create it on an easier level for ...
5
votes
2
answers
3k
views
Save data to custom field columns using entity_metadata_wrapper
I have a simple custom module that creates a new field type. The field has multiple columns in the database; the idea is that a user (or code) will enter a single value, and then that value is ...
5
votes
2
answers
2k
views
Displaying the contents of a document file (doc, docx, etc.)
I'm looking for a way to display the contents of an uploaded document file such as a .docx file.
In Drupal 6 I used the iPaper module which did the trick as all I needed was api code to connect ...
5
votes
1
answer
269
views
Make variables outside of node available to pathauto
I'm trying to port a website over to Drupal 7. The structure consists of locations which have an entity reference to a region which has an entity reference to a country:
location<-region<-...
4
votes
0
answers
356
views
Is ContentEntityBase::access affected by hook_ENTITY_TYPE_access?
Are calls to the access() method on entity objects which is provided by ContentEntityBase affected by hook_ENTITY_TYPE_access()?
I am asking because the Paragraphs module, in src/...
4
votes
1
answer
964
views
How to fix "Unable to save a field collection item without a valid reference to a host entity" error?
I programmatically created a series of custom content entities which contain field collections. My site had an execution timeout error in the middle of entity creation and saving.
I can not delete ...
4
votes
0
answers
394
views
How to create additional base fields for ECK entity
For example I want to create a Vehicle ECK base type and Car and Truck bundles, but I want to define fields for the Vehicle base type that would be shared between Car and Truck.
In UI, by default, I'...
4
votes
1
answer
687
views
EntityFieldQuery with Workflow
I need to filter an EntityFieldQuery with a given workflow state, let's say workflow it is state 21 (sid = 21). Below, the query I am using
$query_formularios_completos = new EntityFieldQuery();
$...
4
votes
3
answers
1k
views
Get field_collection values in field template
I have installed field_collection and have a collection called field_contact,
each entry of which has a field called field_contact_url
I'm trying to customise the display of that field by overriding ...
4
votes
2
answers
1k
views
Upload file and fill in fields in one step; or trigger a rule when a file is uploaded
I want to make use of the Media module and the File entity module to upload files, in particular images, to my site without having to attach them to a node. Solely uploading images works like a charm, ...
4
votes
1
answer
188
views
Node reference solution for a content type which referenced to two fields. (company, product & review)
My website has three content types: company, product & review.
1). The product has a field referenced to a company node using Node URL Reference module.
2). The review has two fields, one ...
4
votes
1
answer
106
views
How to set up a question/assignment pool for a course website?
I have done quite a bit of Drupal work in the past, but am a bit stuck on this one. The basic idea is that the site will offer 1-on-1 tutoring to students. There will be there levels of users: ...
3
votes
0
answers
173
views
How to properly extend Entity Query class?
I am working on some complex aggregate reporting that pulls from several sources (node type) and generates a report in a table display. There are about 10ish line items (could be more later) and ...
3
votes
1
answer
216
views
Pass arguments to the entity_browser iframe url (modal)
I have a form I have a field of type Date Range, I also have another field of type entity_browser(modal) with a selection view widget.
The normal behavior when I click the Button of the entity browser ...
3
votes
0
answers
337
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. ...
3
votes
0
answers
728
views
Change field type for custom entity (from integer to decimal) with existing data
Yes I have seen previous answers about that, but I'm looking for an new answer :
That does not use SQL request
That does not use deprecated function like db_change_field()
maybe that uses the new ...
3
votes
0
answers
414
views
How can I attach a paragraph to a node using hook_node_update()?
I am trying to attach a paragraph whose value comes from a custom field to a node, in hook_node_update().
I tried with two different implementations. Neither of those work.
function ...
3
votes
1
answer
112
views
How to load an entity definition?
I need to load an entity definition to add a constraint and test it, I found that this is possible with the following code:
$manager = \Drupal::entityDefinitionUpdateManager();
$entity_definition = $...
3
votes
0
answers
989
views
Entity query - using parent/grandparent ids as a condition
I have relationships linking a node to a child paragraph, with a grandchild paragraph:
Node
|_ paragraph child
|_ paragraph grandchild
Using an entityQuery, I can get child items using ...
3
votes
1
answer
44
views
Create an Entity (Beginner)
beginner here,
I am trying to follow the typical entity example and create my own entity in Drupal 7. So I basically changed the name from typical_entity_example_1 to source_entity and the test fails ...
3
votes
1
answer
68
views
How do I examine an entity's update SQL statement in order to write a unit test?
I have a core patch (https://www.drupal.org/node/2342699) which ensures that SQL updates do not include the primary key in the field list. I need to write a unit test for this issue and EntityApiTest....
3
votes
0
answers
145
views
Template name suggestion for multivalue image field in paragraph module?
How can I create a dedicated template name suggestion for paragraphs multi value image field?
The below HTML comments are the theme hook suggestions added by the debug function, for the paragraph ...
3
votes
1
answer
2k
views
Entity Browser in Forms API
I'm having trouble getting the entity browser widget to work correctly in a custom form. Just wondering if anyone has had any success in getting it working. I've got to the point the button is ...
3
votes
0
answers
66
views
How do I get back JSON value using entityform?
I am using drupal 7 entityform in this case, as i want CRUD functionality with the form. Can anyone tell me how should i configure my services.
As of now i have configured it manually, selected the ...
3
votes
1
answer
258
views
How to make custom entity type revisionable with existing content?
I'm trying to make a custom entity (with existing data!) revisionable, but I run into multiple very serious issues including schema update errors, difficulties with creating revision data for existing ...
3
votes
1
answer
89
views
Customizing the display of properties on a rendered entity
I have a custom entity with a large amount of properties on it.
We want to format these entity properties to look a certain way, without modifying the underlying data in the table.
What is the most ...
3
votes
1
answer
729
views
Editing a Field Collection element in a custom module
In a custom module, I'd like to to edit a Field Collection element. The element is linked to a taxonomy but I think the code would look quite similar if it was to a content type.
I've read a lot of ...
3
votes
0
answers
1k
views
Drupal 8: set (sub) fields of the address field optional (not required)
I need an address field that allow the user to encode only a country OR a country with some other fields he could choose freely.
I other words, I need an address field without any required field.
To ...
3
votes
0
answers
1k
views
How set default value for entity reference field
I want set a default value for my entity field reference refer to his parent.
I am on his parent and with a link i load a popup with the form of the child :
My parent is in the URL param value 2 for ...
3
votes
1
answer
878
views
How to add a class to the <a> link elements within a Multiple Values field in a View?
I have a Views field (in this case, taxonomy term references) with Multiple Values set to "Display all values in the same row", using the Link formatter and a seperator. I want to add a class to each "...
3
votes
1
answer
104
views
How do I edit the output of a field?
I am creating REST API using Services Module in Drupal 7.
I have created a View to Get lists of Groups. In this views, I have added a Field privacy which will tell if the group is Private or Public.
...
3
votes
0
answers
612
views
How to export entity instances created with ECK?
I have created my custom entity types (and bundles) using ECK module.
Is it possible to export entities from website, for example using Features?
I have found this thread but as I understand, it is ...
3
votes
2
answers
3k
views
How to add UniqueField constraint on integer field?
The title basically says it all. I have the following field definition in an Entity class:
$fields['code'] = BaseFieldDefinition::create('integer')
->setLabel(t('unique code'))
-&...
3
votes
0
answers
582
views
Split multi-value field across columns in table View?
I have a Taxonomy with a geographical hierarchy (Region > Province > City > District), which I'm adding to nodes using the Hierarchical Select module. Because I set the field to "store the full ...
3
votes
1
answer
760
views
Webform description allowing HTML
I'd like to allow HTML in my webform field descriptions. I don't need an editor of some sorts; just the basics like and tags and stuff. How can I edit my webform to allow these tags in the ...
3
votes
1
answer
1k
views
Changing decimal field scale and precision using database
I'm using a custom decimal field in a custom product type in Drupal commerce. It has a precision of 10 and a scale of 2 (2 digits to the right of the decimal place).
I have a client with a large ...
3
votes
1
answer
1k
views
Entity Translation for custom entity
I've created a custom entity and in the next step, I would like to use the Entity Translation module to make the entity translatable.
My entity is defined like this
/**
* Implements ...
3
votes
1
answer
703
views
Accessing content for a specific node revision via a relationship in Views
A module I've written implements hooks defined by the Field API to provide a custom field for defining references to specific node revisions by storing vids. (The module borrows functionality from the ...
3
votes
2
answers
653
views
Strip HTML tags from Field Collections in Services Views
I'm trying to strip the HTML tags from a JSON response I generated using Services Views, but I'm not having any luck so far.
I have a content type with a Field Collections field in it that is ...
3
votes
1
answer
159
views
is there a module for instagram like YouTube Field?
I need a module that permit to my editor user to choice photo from instagram and linked them in a field of a content type.
I have found https://www.drupal.org/project/instagram_feeds but I don't ...
3
votes
2
answers
990
views
Inline entity form shows a content type select list
I am using Inline entity form for a non-commerce project.
The settings are:Widget:multiple values,Node:Allow users to add existing content.
Mode:Views:Filter by Entity reference view.So I have created ...
3
votes
1
answer
2k
views
Saving values of a multistep form into custom entity fields
I'm building a module that implement a multistep form based on a custom entity.
The entity contains fields which are created by the install file.
I was able to create the steps and if I print the $...