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
2answers
509 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 ...
2
votes
3answers
869 views

How to hide specific term/field value on the node?

Is there a way to hide a specific taxonomy terms (specific field values) on the node? (not hiding field/vocabulary altogether, just some values). For instance, there is vocabulary "Location" with a ...
1
vote
1answer
497 views

Creating Parent-Child Entities

Is there a way to create parent-child entities in Drupal 8? I'm trying to create a structure where the top entity is for County, and the next level entity is for departments, and next level would be ...
3
votes
5answers
4k views

How to check if entity's property has a value

How can I check if entity's property has a value? I don't think this is the "drupal way" to check it like this $page_optimization->title->value() !== '' Is there any method, something like $...
0
votes
2answers
40 views

Can I add and edit a custom entity from the same URL?

I am creating a custom entity called user_profile. Each logged in user will have a user profile. I want to be able to add and edit the user_profile entity from the same URL. The example module ...
0
votes
2answers
381 views

Feeding JSON into a Content Type and allow for updates

So I have a JSON feed coming from a provider that I'd like to turn into a node type for D7. Within this feed we have a lot of common things like Bios, Names, Pictures, stats, etc. This feed can ...
0
votes
1answer
15 views

Entity Validator failing Integer for not being integer

I have a custom entity with an integer field with the following baseFieldDefinition: $fields['permission_level'] = BaseFieldDefinition::create('integer') ->setLabel(t("Permission Level")) ...
2
votes
5answers
3k views

How to delete all Taxonomy terms of particular vocabulary using entity_delete_multiple?

I want to delete all taxonomy terms of particular vocabulary using entity_delete_multiple. For node it is working fine $result = \Drupal::entityQuery('node') ->condition('type', 'page') ...
1
vote
1answer
7 views

How to copy/clone menu of a node when clone with Entity Clone module?

When cloning a node using Entity Clone module, the menu link are not copied. As menu link item is created and managed on the node form level, there is no reference of the menu link item in the node ...
2
votes
1answer
1k views

“Valid date is required for date_1” error while using drupal_form_submit()

Field : field_date_1 Type : Date Widget : Pop-up calendar The settings for date field is as shown in 2 images I get the values of a form_state into the $source_node and move that to $fs variable....
3
votes
1answer
1k views

Is there any documentation for the UUID module?

I think I need to utilize the UUID module to make universal ID's for some taxonomy terms. However, after installing the module it doesn't seem to do anything and the configuration interface has only ...
0
votes
0answers
28 views

Get a parent Paragraph's field values from hook_preprocess_field_collection_item()?

I'm trying to update the value of a field within a Field Collection item using hook_preprocess_field_collection_item(&$variables) but the value I need to reference is in a parent Paragraph Entity. ...
-1
votes
0answers
19 views

I want to be a Chinese poetry class web site, but I don't know what can realize, please help me! [closed]

There are two main requirements: 1.Click the first option, according to Chinese pinyin of each text 2.Click on the second option, the meaning of each sentence My idea is that (1) each text quotes a ...
0
votes
1answer
1k views

How can I add a currency field to a content type?

I would like to have a field that accepts U.S. dollar amount. I installed the module: https://www.drupal.org/project/currency. Structure > content type > I do not see a field type "Currency". I am not ...
1
vote
1answer
391 views

Absolute URLs instead of relative

I have a problem with entity URLs in D8. All of them are absolute instead of relative, which causes various problems. For example,link URLs to edit content on /admin/content look like this: http://...
0
votes
1answer
392 views

How to get Address Field to display correctly with Autocomplete?

I want to create a postal field for addresses in the Philippines. I have set up a sandbox site with a content type that has just one field, of type addressfield and using the autocomplete widget. ...
0
votes
1answer
511 views

Get text_long field value with EntityMetadataWrapper

I am trying to get data from a text_long type field using EntityMetadataWrapper, and from what I'm seeing on the interwebs, I should be using something like this: $wrapper->{$field}->value(); ...
5
votes
2answers
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 ...
-2
votes
0answers
34 views

How to get entity field value for computed field?

How to get entity field value for computed field? I have field "field_ingredients", it has values "allergents", "cancergens" etc. $value =$entity->field_ingredients->value; $display_output = $...
1
vote
1answer
393 views

How to print the raw value of a custom user field in comments

I want to print a custom user field of the commenters. It is an Link field (https://www.drupal.org/project/link). Some users have that field completed and other not. I've read a lot of posts related ...
0
votes
0answers
15 views

How do I retrieve the individual elements that make up an entity?

I have some entities (called media_item) that each consist of a collection of images (small, medium, large). I would like to pro grammatically select the large image path from one of these entities ...
0
votes
2answers
453 views

How to hide field if blank

I have a view created which has a column 'Price'. I also I have another column 'Special Price' in the same view, but 'exclude from display' is selected. In views, click the price field > rewrite ...
0
votes
1answer
31 views

Adding Field To Bundle-less Entity On Installation Not Working

I have several fields that I'd like to attach to a custom entity upon installation. I am trying to follow the suggestions here to attach fields to my custom entity (which, by the way, has no bundles). ...
0
votes
1answer
328 views

How do I make the nodes referenced by organic group content also be OG content?

I have an organic group called 'newsletter'. I have two content types - 'issue' and 'article' - in 'issue' (which is set to be a group content type), there is a node reference field to articles, and ...
0
votes
0answers
33 views

Type-specific fields for different categories of content type

I have a contract content type on my Drupal 8 site, and I would like to use the same content type for multiple different types of contracts. 95% of the fields are common for all types (contact ...
0
votes
0answers
10 views

D8 Equivalent To D6 Node Referrer - Obtaining List Of Referencing Entities On An Entity

I am refactoring a D6 site into D8. Two of the entities (content types) I have are Event and Document. There is a 1:n relationship between Event and Documents. I added 'For Event' field on Document ...
1
vote
2answers
599 views

How to set and inherit variables within different twig templates?

I'd like to set a variable in my node.html.twig template: {% set title = label %} {{ content }} The content consists of one field visible only, which has it's own template: file-link.html.twig How ...
1
vote
1answer
349 views

Export translations of field labels

Drupal 7. I work on multi language site. I have a content type with entity translation fields. I've added translation to field labels and settings on my DEV copy of site and now I need to export and ...
0
votes
2answers
330 views

Relationships Between Nodes on Field

I'm trying to work with some information out of our enterprise system to create an employee directory, and I have a question regarding how I can relate nodes together. I have a content type called ...
0
votes
2answers
332 views

field_get_items / value when creating new content

I think I am about to lose my mind .. how in earths name do I get the value of a field in a widget during creation? I created a custom field widget, and during creation of new content I want to be ...
0
votes
1answer
447 views

Alter title link in taxonomy view mode

Under /admin/structure/taxonomy/my_vocabulary/display/entity I've got a view mode "entity". For this view mode, I would like to alter the way the link in the title field is built (the title is ...
0
votes
2answers
353 views

Node value from form state

I have a node which I want to update from a form states values. I can set each value individually like: $node->set("foo", "bar"); Is there a way to mass assign the values instead of setting each ...
0
votes
1answer
18 views

Programmatically create new Schedule Updates Entity Reference on Node

I’m attempting to populate an entity referenced field created by the Scheduled Updates module within a content type, Event. Within Event I have two Scheduled Updates fields to check and uncheck the ...
0
votes
1answer
792 views

searching and entity references

I have two content types documents and authors. When creating a document a selection list of entity reference's to authors is used to select the author. Searches for the author name find the correct ...
0
votes
2answers
444 views

Custom field “required” validation

I built a custom field type using the Field API. In hook_field_validate I have some logic to validate some very custom stuff, but when I tried to add a "This field is required" validation, I realized ...
0
votes
1answer
337 views

pass result of Rules loop to variable to use outside loop

In Drupal Commerce, i have created a rule that calculates the price by adding some fields (custom line items), and then sets a result. Now i want to make a loop (to pass over fields of a Field ...
0
votes
1answer
343 views

Display order of entity reference fields

I have an entity reference field which references and displays multiple nodes on a Drupal 7 install. I am trying to get them to display in date order (the date is a field on the referenced nodes). ...
23
votes
2answers
27k views

Programmatically update an entity reference field

I know I can update (or set a value for) an entity reference field in Drupal 7 with code similar to the following. $node['field_code_used_by'][LANGUAGE_NONE][0]['target_id'] = $id; I want to ...
4
votes
1answer
473 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 ...
0
votes
1answer
24 views

Display text in an empty field group tab using custom code

I have created a field group with an empty tab. I would like to use custom code in a module to display something in this empty tab - it will just be a render array. Can someone show me how this can ...
1
vote
1answer
331 views

How to specify entity reference fields when programmatically submitting to user_register_form

You'd think this would be easy. I'm calling drupal_form_submit('user_register_form', $form_state) to automatically register users after they have completed filling out a Webform. But I have some ...
0
votes
1answer
342 views

Views Exposed Filter Sort on Entity based on Term Reference Field from Entity Reference Relationship

I've been playing around with Views exposed filters on an entity. I have so far been able to create a relationship to another entity through an Entity Reference, and exposed the fields belonging to ...
2
votes
2answers
83 views

Loading taxonomy terms in a tree in Drupal 8

I have multiple level of vocabulary, I want to display all level in the hierarchy same as taxonomy display. My taxonomy is like. All Drinks Alcohol Drinks Beer Vodka ...
0
votes
1answer
442 views

Field-Group Tabs not displaying on product page

I'm trying to display a handful of fields as tabs on my product detail pages, but it seems that the field-group tabs are being completely ignored by the Commerce product display. Anyone else have this ...
1
vote
2answers
374 views

Field available only when a value from a Hierarchical Select is chosen

I am using a Hierarchical Select that enables a user to first select a continent ( first select ) and then a country ( second select ) I wish however to enable a field ( text ) only when a user ...
0
votes
1answer
358 views

Nodes containing simple field collection not displaying properly

I have a content type to which I added fields like description, image and a field collection containing two simple text fields. Editing and viewing in the backend (logged in as admin) works properly. ...
5
votes
1answer
57 views

How to save custom label as parameter for a custom entity_reference field widget?

I am creating a custom field widget for an entity_reference field. This has a custom select field and an Ajax Submit button. Once the user selects an option (entity) from the select_field and submits ...
2
votes
1answer
354 views

Making File Field description required

My users always skip adding the "description" to the file field because they can. I tried implementing the code posted here: How do I make Drupal File Description Field Required? (and thank you) -- ...
2
votes
1answer
360 views

Referencing nodes reciprocally

I have a content type called Project which can relate to n projects of the same content type. This is done with a field called related projects using the D8 core Entity References. A possible ...
0
votes
1answer
488 views

'<Hidden>' a field on Manage display

I'm using D7. If you set a field <Hidden> on 'Manage display', and, unless you display it by views or something, you cannot see it anywhere on the site, right? They say... Format The ...