"Entities" is the term that in Drupal 7 is used for nodes, comments, taxonomy terms, and users. Third-party modules can then define new entity types.

learn more… | top users | synonyms (2)

0
votes
0answers
7 views

How to autopopulate entity reference field w/ user-created entityform submission

I'm developing a website for recruitment for research associates. I am currently using Entityforms as the questionnaire. I've created a rule to create an entity of a certain content type, which I ...
2
votes
1answer
16 views

Correct way to validate config entities?

In Drupal 8, how do I validate a ConfigEntity? I tried adding constraints, but then I found out this only works for ContentEntity, not ConfigEntity. My ConfigEntity has 2 fields, and the options of ...
1
vote
1answer
19 views

Add value to field using Entity Metadata Wrapper

I'm trying to accomplish the seemingly simple task to add a value to a multi-value file field in Drupal 7. I have been trying for hours, but none of the answers I found would solve my problem. My ...
1
vote
1answer
21 views

Converting a helper class into an Entity

I am working on a Drupal 8 module, and a separate module of examples, on how to use the first module. In my example module, I have a function in my controller that looks like this: public function ...
0
votes
1answer
21 views

Get menu item of a content type

Is it possible to get the menu item of a certain content type through the API? The idea is to improve Markus Orenstrat solution to set the active trail based on the content type. As it stands it ...
0
votes
1answer
13 views

Extra aliases in the url_alias table

In a module, entity_save is being called 2 times. Each time it's called, an extra alias row is being added to the url_alias table. I couldn't find any paths being saved in node_save. Is this expected ...
3
votes
2answers
34 views

How to use entityQuery to select if a multiple value entityReference field does not contain the id

I have an entity with a user entityReference field, which may contain multiple values. I wish to select using EntityQuery the nodes that do NOT contain the uid in the query. $query ...
1
vote
0answers
19 views

Programmatically insert commerce stock failed

I am using this code to insert the commerce stock but it fails some how: $cp = commerce_product_new($product_type); $cp->is_new = TRUE; $cp->revision_id = NULL; $cp->uid = 1; $cp->status ...
0
votes
1answer
22 views

How do I get both published and unpublished records using entity query?

How can I get both published and unpublished records for a content type using entity field query? As per documentation we can filter records by status either published or unpublished. But I need all ...
4
votes
1answer
32 views

How to auto-assign a user a particular role when that user gets autocreated in a content form?

I need to auto-assign newly autocreated users from the content editing form a particular role. I created this new content-type : Music Track and created a new field - Artist for it. The Artist field ...
0
votes
0answers
13 views

How do I alter entity reference autocomplete results [duplicate]

I have an Album content type with some fields, including a contact field, which is an Entity reference field (taxonomy). My contact taxonomy field has 3 text fields. I want to be able to add a ...
0
votes
1answer
17 views

How do I get the content type of a node entity from the $entity object?

I'm using hook_ENTITY_TYPE_presave() to alter the values of nodes upon saving, but I only want to do this for a specific content type. How do I check the content type of the $entity object? I looked ...
0
votes
0answers
15 views

Migrating to entities not nodes

Can the Migrate module import entities? I have pretty much 'mastered' writing my own custom node migrations and executing them in drush ( bty, thanks to the makers, I love the module). However, I'm ...
3
votes
1answer
28 views

Field Collection vs. Paragraphs

I used Field Collection in my previous sites and I faced some performance issue, So this time i am looking a alternative for Field Collection. I find a answer Alternative to Field Collection. but I ...
0
votes
0answers
7 views

Entity Metadata Wrapper - Date field without end date

I'm creating programmatically one content type using entity_metadata_wrapper. I'm copying a date field (without end date) from another wrapper. I found this documentation quite good here: ...
1
vote
1answer
22 views

Entity reference default value to first value

I have an entity reference field using a view to dynamically create a list based on a contextual filter from a user ID in URL. Works perfectly. Question is, how can I default the value to the first ...
0
votes
0answers
16 views

How to programatically create availability calendars for each node [Solved]

I'm working on a booking page on which i need to programatically add an availability calendar for each property element (node). All the data comes from external sources and is imported ...
1
vote
0answers
23 views

how to add UniqueField constraint on integer field in Drupal 8

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')) ...
0
votes
2answers
18 views

Does having too many cck fields negatively affect site speed and performance?

I building a site that could potentially utilize 50 different content types. The most of the content types have more than 40 CCK fields, including multiple field_collections entity_reference. How can ...
0
votes
1answer
20 views

How to properly compare values of two identical entities?

I have a custom entity that is not revisionable and I need to store any differences made by the user - and only differences, so if nothing has changed there should be no entry. I am doing this in ...
3
votes
3answers
44 views

How to create paragraphs item programmatically?

How to create paragraphs item programmatically? In Drupal 7 I am using the following code. $node = node_load($nid); $paragraph = new ParagraphsItemEntity(array('field_name' => ...
0
votes
2answers
41 views

Programatically render field in specific language while leveraging core content language detection

I'm working on a contrib module port to D8 and can't seem to find appropriate Entity API documentation to figure out how to get a rendered field in a specific language. I have a controller that needs ...
1
vote
1answer
66 views

How do I alter the node entity?

Maintainer of Custom Publishing Options here... trying to figure out how to port to 8 in a clean way. https://www.drupal.org/node/2647410 I have config entities working, so I can define custom ...
1
vote
1answer
21 views

Why can't I programatically create a location field in a node?

I'm trying to programmatically create a node with a location field, but I'm not able to do it. I have done it in a similar project and it works fine. I use the Entity API module to create the nodes, ...
3
votes
2answers
35 views

How to get bundle label from entity

How do I get the human-readable label of a bundle from a loaded entity. Lets say I want to get the label of a node of bundle my_article which is "My awesome article" // Load a node $node = ...
1
vote
1answer
44 views

How to get a list of entities available in your Drupal?

Sometimes I need to create a new entity but I don't know the exact machine name of the entity to put in the entity_create() method. Is there an easy way to check which entity types are available to ...
0
votes
0answers
31 views

Reuse Block's visibility settings mechanism for custom entity

I'm on Drupal 8. I'm writing a module where I want to have custom entity which will reuse Block's visibility mechanism. I don't want custom block type, I don't want my custom entities to appear as ...
0
votes
0answers
10 views

Drupal Field Api Form widgets for Entity Properties in Custom Drupal Entities edit forms

Is it possible to use Field Api form Widgets in Custom Entities submit forms? There are times when an Entity Form or any other custom entities has a lot of fields, which surely makes a huge impact on ...
0
votes
2answers
53 views

Programmatically updating a node

I can create a node using the following code: $node = \Drupal::entityTypeManager()->getStorage('node')->create($array); But if I have the node ID, how can I edit a node?
0
votes
1answer
32 views

Find entity id in database

I am currently moving a website from Drupal. The information I need to transfer is divided to many DB tables and connected through entity_id (That is my understanding, I have no experience in Drupal). ...
3
votes
2answers
82 views

Remove entity type without module uninstall

I created entity type my_entity in my module. But now I don't need this entity anymore and I want to completely remove it without module's uninstall. I want to remove both definition and all database ...
0
votes
3answers
46 views

How can I react when a commerce product is explicitly created via the UI?

how do we add a submit handler in drupal commerce everytime a product is created. I tried using the following code. function custommodule_formid_form_alter(&$form, &$form_state, $form_id) { ...
1
vote
3answers
164 views

Which method has better performance

I want to update some term id on some node (let suppose 1000 node),My changes is convert all news node with category(term_id) = 3040 to category(term_id)=5). I know I can do it with several methods( ...
1
vote
1answer
13 views

Feeds Import - Entity Reference mapping

I have a "Buildings" content type. Within that content type I have a building_id field, which contains the building ID. I have an "Employee" content type. Within that content type I have an entity ...
0
votes
0answers
8 views

Data Processor missing from Feeds' 'Select a processor' view

I installed the Data, Schema, Job Scheduler, and Feeds modules in Drupal 7 and am not seeing the "Data Processor" on the Feeds' 'Select a processor' view when creating a new importer. I even created ...
3
votes
1answer
41 views

drupal commerce for timeslot book?

I am thinking of setting a product that is only valid from a period of time eg: product a from 15january2016 til 15january 2018, upon this setup it will be available from that period of time. also ...
0
votes
0answers
21 views

Add set of fields to every field - how to implement?

We have a new requirement that we need to keep information (a set of attributes) associated with every field of content type A. This is essentially meta-information about any given field's data. (I ...
5
votes
2answers
59 views

Why is hook_schema() called twice?

I'm working with entities and, in trying to troubleshoot another issue, I noticed that hook_schema() is called twice each time the module is installed. This happened even with a bare bones test module ...
0
votes
0answers
15 views

what is the hook to use after a product is created via drupal commerce? [duplicate]

wondering what is the best hook to use after a product is created via 'admin/commerce/products/add/products' to goal is to get the id of the product created programmtically then create a clone of it. ...
1
vote
0answers
9 views

Entity with ECK: image is there, but it doesn't render properly

I've created a new entity type with ECK and added an image field. All is well: I can create an entity and add the image, on the edit interface it shows up properly. However, when I display the entity, ...
1
vote
1answer
43 views

How to pass metatags from a node into a view?

I'm sending my information of my node into an external application and I need to be able to send the metatags of that node as well. Unfortunately I do not see the metatag fields. My question is... ...
1
vote
1answer
8 views

sharing profile2 fields multisite

I have a site with 2 multi site like abc.com xyz.abc.com zxy.abc.com All sites have same drupal 7 code base. and I shared all users successfully across all portals. my setting file for sub-site ...
0
votes
2answers
51 views

How to get instance of referenced entity?

I have a node object with image field named field_image. When I do $node ->get('field_image') ->first() ->getValue() I get array with some properties instead of entity object. The ...
0
votes
1answer
24 views

Is there any other way to create a “settings” node without having to create a Content Type?

I need to create something like a node with settings. This will have custom fields, images, etc... Just like a content type, but without having to create one of them. Why? I think it's strange having ...
0
votes
2answers
29 views

Adding Pager to entity referenCED field display

I have two content types: Parent and Child I have an entity reference field (called "Link") in parent content type referencing it to child content type. I am using inline entity forms module for the ...
0
votes
2answers
36 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
17 views

How to create an entity handler that accepts arguments?

I've created a module and entity using Drupal Console. It defines a canonical route like this: entity.score.canonical: path: '/admin/score/{score}' defaults: # Calls the view controller, ...
0
votes
0answers
16 views

Is there a base form for fieldable entity settings?

I've build custom entity by extending ContentEntityBase class. It's very similar to the entity from content_entitity_example. I'd like to allow users to manage fields display the same way they can do ...
0
votes
0answers
7 views

Does node_save() actually rewrite its saved node's entity cache, or does it just clear it?

From what I can tell, Entity API maintains an in-memory cache of all nids/entity IDs it's loaded over the course of the page request (and beyond the request, when using memcache maybe?). When a node ...
0
votes
1answer
18 views

change entityform value via function before save

I have an entityform with a field call "IP" (field_ip is its machine name). Now I need to set a value before that the entityform is saved. I have thinked to use hook_entity_presave() in this way: ...