Questions tagged [entities]

Nodes, comments, taxonomy terms, and users, using the terminology used since Drupal 7, are generally called "entities."

Filter by
Sorted by
Tagged with
0
votes
1answer
958 views

How to call preprocess functions from my custom module

I have created a custom module that declares a custom image formatter. Now I need to call the Core image module preprocess function 'template_preprocess_image_formatter'. How would I do that? I tried ...
0
votes
2answers
469 views

Extract First Name and Last Name from the Title field in Drupal 7

In one of my content type, we are storing names in the Title field. Due to the recent requirement change we now need to sort results by last name. But since the name is stored in Title how can I ...
1
vote
1answer
424 views

Use computed fields as Apache solr facets

Today I wanted to add a computed field to my facet to make a faceted search using that field but when checking the facets page that field wasn't in the allowed field to make facets. When i realized ...
0
votes
1answer
413 views

How to get “Add another item” option for fields based on taxonomy terms

The goal is to allow an autocomplete field that uses taxonomy terms, and which allows multiple entries from the same taxonomy list – for example a list of names & contact info for a field that ...
1
vote
1answer
458 views

Views math expression or Computed field to find date difference in views

I have two content type, Bill (Type1) and Cash Receipts (Type2), Type2 referencing Type1 when cash is received. In Type1 I have date field called (Bill Issue date), and Type2 I have date field cash ...
0
votes
3answers
493 views

how to automatically create other entities when creating an entity

I have 4 entity types. All types have a relation to each other. For now let's call them A, B, C and D. How can I allow a user (let's say userA) to create an entity of type A so that entities for B, C ...
3
votes
1answer
452 views

Altering ImageField Widget with FUpload enabled

I need to alter the ImageField Widget so that I can add some fields other than the Description, Alt and Title fields. I'm able to do this when I select the file field widget type as Image Uplaod, but ...
2
votes
1answer
458 views

default value when adding new item of date field

i'm using drupal 7 and in my content type there is a date field has start and end value with unlimited values, i set the default value to "Now". but the problem is when adding new item of this field ...
0
votes
1answer
26 views

How can I programmatically create an entity with an entity reference field?

I want to create an ECK programmatically, I can create it but the issue is with the entity reference fields that being empty The interesting issue is that when I try to edit the created entity, just ...
1
vote
2answers
448 views

How do I use print to generate a PDF of all entities referencing a specific node?

I'm trying to use the Print module to generate pdf's and epubs of the stories on my site. However, I need to get Print to generate these files from the story page and then generate the pdf with ALL ...
0
votes
1answer
459 views

List field: translated values are not translated

In my Drupal 8 project I have some list fields. For example maybe a field "project type" with the following key|values, coming from the original language German: 1 -> öffentliches Projekt 2 -> ...
1
vote
2answers
628 views

Entity form submission sending email

I'm working on entity form using the module "eform" in D8. I would like it to send email when the user submits a form. It was done using some other modules rules and entity rules, but since "entity ...
0
votes
1answer
436 views

Adding Quick Tabs Programmatically to a node is not working

I'm writing below code in my node--type.tpl.php, but only empty page is loading when i load the node page.Can you please help in knowing my mistake. What i need to add to display quicktab and its ...
2
votes
2answers
561 views

Show custom banner per page

Admin user wants to be able to upload image banners and select on which pages/nodes/views/panels to show it when visited (as a wide screen image banner above title). It means when creating the banner ...
0
votes
1answer
421 views

Custom Validation on Address Field

In addition to the validation that already takes place using the addressfield module, I'd like to check for (and fix) items like: Building to Bldg Room to Rm Circle to Cir Avenue to Ave Is there a ...
0
votes
1answer
445 views

Suddenly unable to add a field to a new content type

When editing a content type I was going to add a simple boolean field to an existing content type. When attempting to add the new field Drupal threw an error. After a few more attempts to add a field ...
0
votes
1answer
445 views

View displaying field collection items based on taxonomy term

I have a set of nodes that include a field collection item GeoImages. (Each node can contain multiple Geoimages, if that's relevant). Geoimages includes (among other fields) an Image and and Image ...
1
vote
2answers
444 views

How to sort view by a field that is part of a field collection?

I had searched solution for my problem, but I didn’t found anything good. I have custom a node type Client with Field Collection Product. My field collection has two fields: name of the product ...
2
votes
1answer
434 views

entity_metadata_wrapper langcode always prints default language

I'm using entity_metadata_wrapper with entity translation to print fields in a template, but it always prints the default language when using a langcode in the options. $wrap = ...
0
votes
2answers
518 views

Edit a form retrieved using FormBuilder::getForm()

I found out how to get a node creation form, but I want to display and modify it (e.g. delete some fields I don't need). This is my code. public function buildForm(array $form, FormStateInterface $...
-3
votes
0answers
18 views

Load entity by ID without knowing the entityTypeId

Is it possible to load an entity if we have only its ID, but we don't know if this is a node or a commerce_order or something else?
0
votes
2answers
355 views

hide field based on its value or value of another hidden field

I need to hide a radio button field of a content type (not a form) only on the edit view based either on its own value or based on the value of another field that is already hidden. Dependencies does ...
2
votes
2answers
507 views

Render fields url in tpl.php

I have a content type (music) with fields(image,track,title). I used a soundmanager player to display my track with its tpl.php(bar.tpl.php). I have tried to display url of the image field inside the ...
1
vote
2answers
850 views

How to display a specific form mode in a programmatically displayed form

I have a custom entity type, property. In admin/structure/display-modes/form I created a new form mode for this entity type, machine name is property.property_status. It only shows one field on the ...
5
votes
2answers
7k views

Add content type field programmatically

My module provides a configuration form which allows to select a content type and on submit 2 new fields will be added to the selected content types. I want to add these fields to the content types ...
1
vote
1answer
453 views

Referencing parent entity

I've just started with Drupal and I'm trying to create the following URL structure with PathAuto and Entity Reference: Category A -> Category B -> Category C Resulting in category_a/category_b/...
1
vote
1answer
445 views

How to get the highest value of a specific field in a multivalue field collection

How to get the highest value of a specific field in a multivalue field collection, USING PHP? This is about displaying the right discount for a marketplace product. There is a node type Product with ...
0
votes
1answer
354 views

Theming paragraph fields from entity reference in view

I have a view (Drupal 8) where I load my entity reference field (display hidden), with three fields from a Paragraph type and a certain custom display). The HTML markup looks like this now: <div ...
24
votes
6answers
25k views

Programmatically attaching files

I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field: $file = file_save_upload('...
4
votes
1answer
532 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 ...
3
votes
2answers
457 views

How do I store large volumes or data points using Drupal ( temperature and humidity points )

I'm trying to use Drupal as a headless API, and so far I'm having good results. One of the things I'm collecting is a Temperature and Humidity data. Thus far I've created an entity that can hold the ...
1
vote
0answers
15 views

Set Default Value of User Entity Reference to logged in user

I have a Drupal 8 installation that has a user reference field and I would like the currently logged in user to be the default value for the field. I believe in Drupal 7 I would've used the [current-...
1
vote
2answers
25 views

Entity access controler not called from custom route

I define a custom entity named "Politician", where I set the class PoliticianAccessControl as an access handler. This is working fine for the canonical url of the entity set in the following way: ...
1
vote
1answer
459 views

Date with an option for end date being either a date or “ongoing”

I have a content type that contains relevant information of a project. It should hold the projects start date and the end date OR the status "ongoing". How do I make this happen? With the date field ...
2
votes
0answers
23 views

how to update FieldStorageDefinition in a hook update?

This is a feeds module related issue. An entity update that started to cause errors on 8.7.x after the removal of automatic entity update. Originally an entity definition needed to be updated using ...
1
vote
0answers
63 views

field_view_value() returns no items in Computed Field

I am trying to compute the value of a field using the Computed Field module. I need to get the formatted value of a field field_get_items() and field_view_value(). I think there should be no problems ...
1
vote
1answer
435 views

Pulling capacity and slots left from entity registration

I'd like to pull the values for capacity and the slots left from a registration created by the entity registration module. This sets up registration entities which are attached to (I believe this is ...
4
votes
2answers
3k views

How to store values to field collection or paragraphs programmatically?

How do I store values to either a field collection or a paragraphs field programmatically? Could somebody please provide a working code example of how you do this? I would have a field holder ...
0
votes
1answer
462 views

Entity form in ctools modal popup, whilst passing in values from current node

I need to open an entityform in a modal popup. I have got this working using 'Modal operations'‎ and 'Modal forms' modules following this guide: http://julian.pustkuchen.com/en/comment/reply/599. My ...
3
votes
1answer
985 views

Specify a node type (bundle) in entity reference field

I have a custom entity type which has an entity reference field. $fields['referenced_article'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Article')) ->setDescription(...
1
vote
2answers
507 views

Cloning entities

i have 3 different entities build with help of EntityApi module. They connected with each other with ID column in tables. Entity - "Purchase" Entity - "Catalog" has 'purchase_id' column in table ...
0
votes
0answers
10 views

Add a FULLTEXT index on specific column

I'm currently implementing a custom search engine in my custom module. In order to optimize my module, I would like to perform SQL queries by using the syntax MATCH....AGAINST in Entity queries. By ...
1
vote
1answer
466 views

trouble with a checkbox on the user registration pages

I created an extra checkbox field for the user registration form This is the field setting page. (Standaardwaarde means "Default value.") In the setting page, the field is unchecked, but it's ...
1
vote
1answer
425 views

How to detect if “Show end date” is checked?

Trying to find a way to get the value of the checkbox "Show end date" on a date field on drupal 7. Is it stored somewhere in the database? Can't find it. Its definitely not in the $node object. Any ...
1
vote
1answer
518 views

How to properly check in entity form validation if field is empty?

I have a content type "A" (Node entity type). In it's node form (new/edit) I need to check if some fields are empty or not (which are not required in general). My first intention was to use FormState "...
0
votes
0answers
41 views

Profile entity type missing form class

Getting following error, Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "profile" entity type did not specify a "employee" form class. in Drupal\Core\Entity\...
1
vote
1answer
901 views

Programmatically create a paragraph entity reference field

I need to create a config page, that is able to add social media information ( name and icon ), the user must be able to add as many social medias as it wants. To do so, I'we created a paragraph with ...
0
votes
1answer
12 views

How to join the `field_data_field_*` tables with `node` table using SQL?

I apologize if I ask for something obvious, but I am asking because I could not find a simple answer anywhere. I know how to work with these tables in the PHP Drupal code, which built-in functions to ...
0
votes
1answer
22 views

Show Content Type Fields from a entity reference

I have a content type which i have linked to another content type. For e.g. Companies (Content Type) Employees (Content Type) When creating a new employee i have to say which company it works for so ...
1
vote
2answers
1k 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). ...