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
0
votes
0answers
3 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
607 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
568 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
608 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
800 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
584 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
970 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
13k 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
345 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
644 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
440 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
392 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
14 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
626 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 ...
3
votes
1answer
760 views

How to programmatically set the field formatter for a field given certain conditions

I have an entity 'house' with an address field. The address field comes with a default field formatter plugin. This is perfect for when i view my entity at its canonical route and where its view_mode ...
1
vote
1answer
1k views

Create an expiration date field that auto expires

We are currently migrating a Drupal 6 site to Drupal 8. We have a view that shows a table of files uploaded through the file depot. One of the columns on the table was an Expiration Date. In Drupal 6 ...
0
votes
1answer
26 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 ...
1
vote
1answer
2k views

How to change Title field label and description for Custom Content Entity [on hold]

I've created a custom content entity (generated via drupal console), I can add custom fields just fine via the cms. What I'm try to do now is change the default label from 'Name' to 'Artwork Title'. ...
1
vote
1answer
870 views

How do I customize node.tpl to print an entity reference field in a specific format

I have content type called collection that has an entity reference field (multiple) that references another content type called books. One the collection node page, I want to render all of the books ...
3
votes
2answers
712 views

How do I get JSON data from a custom entity

I would like to GET JSON data from drupal 8 custom entity. I am using ubuntu 14.04 and vagrant. For that i have done these steps. I have taken reference to Create drupal 8 custom entity from this ...
1
vote
2answers
939 views

Profile field create and set default value programmatically

I need the checkbox to be checked by default. Below is my code, notice the 'default_value' under the settings array. $field_instance = array( 'field_name' ...
1
vote
1answer
2k views

Adding the video field to a content type

We've been using an SWF player for a while. I added the Video module without adding a new content type, just to see if the HTML5 tag worked. It does. However, that obviously doesn't give us an SWF ...
0
votes
1answer
764 views

Cloned node entity reference field stay in sync with parent node

I have three content types A, B and C. A have entity reference fields to B and C. I create a Node of type A say a1. When i clone a1 node as a2 with node clone module i get the same value for entity ...
4
votes
2answers
1k views

How do I filter by node ID in views?

I am trying to add Node ID in contextual filters but it seems there isn't Node ID anymore.
2
votes
1answer
75 views

How to add a theme preprocess function for published state?

I want to create a body class for the published state of a node. I found some suggestions below for Drupal 7, but this code is not working for my Drupal 8 theme. Add class based on published state ...
2
votes
2answers
747 views

creating nodes with many to many relationship type with some fields?

This is in line with How to structure a "many-to-many" relationship between nodes. To keep things in line with the example from the linked thread, what if i was a book warehouse and i had ...
0
votes
1answer
567 views

CCK checkbox or dropdown widget as a field?

I am trying to setup a new CCK field for a content type to display as a checkbox but I see I don't have that option in the widgets type. Shouldn't that be included in the default CCK? I am using the ...
2
votes
2answers
410 views

How to display custom data array via Twig

I've created service which gets the raw data from custom content type. It looks like this : Array ( [front_page_slider] => Array ( [1] => Array ( ...
21
votes
3answers
17k views

How do I render nodes, now that node_view() has been deprecated?

In Drupal 7 I frequently use node_view() for rendering nodes (using view modes) in blocks or pages as follows: $nids = array(123,456,789); $nodes = node_load_multiple($nids); foreach ($nodes as $node)...
5
votes
1answer
460 views

Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

I have always known that loading multiple nodes at the same time is faster than loading them one by one. What I wasn't aware of, is the huge performance difference between the two ways of loading ...
-4
votes
0answers
18 views

Custom module role [closed]

Have created a custom entity and added a new role of publisher through back office. How to assign 2 operations, create & update for the publisher role for the created entity only through code?
0
votes
1answer
21 views

Referencing “type” in nodes returned by loadMultiple();

I know there are easier ways to sort nodes by type, using views, or using: $query->loadByProperties(['type' => 'my_content_type']); ... but what I really want to do is return ALL nodes and ...
1
vote
3answers
777 views

How to implement access permissions per individual field and individual nodes?

I know there is https://www.drupal.org/project/field_permissions module, which allows to set field permissions per role, however what I need is to provide each individual field access permissions. As ...
83
votes
8answers
16k views

When is it appropriate to create an Entity versus just adding a new content type?

What is the benefit to creating new entity types over just building a new content type? It seems a bit overkill to do all of the custom coding that is required to create a new entity when you have ...
1
vote
1answer
931 views

How to alter inline entity form fields on node edit drupal

I want to hide some fields of product reference on node edit. My purpose is to unset or set access to false for colors or price field of line item included in node as inline entity from in a content ...
1
vote
1answer
913 views

How to calculate the average ratings for the post when the user submits 3 field ratings?

I need to implement ratings in my site. I have user five star rating and voting API module, I created a content_type with "beach", and created some field in the manage field settings, name, id, etc. ...
0
votes
1answer
18 views

How can I filter which entities are available in the admin form for an Entity Reference Field? [duplicate]

I've got a Field which is called "Primary Article" which is an Entity Reference Field. I've configured this field setting the "Reference Type" to be "article", so that only articles show up in the ...
3
votes
1answer
797 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 ...
6
votes
2answers
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 ...
1
vote
2answers
974 views

Body field data disappeared

EDIT: Looks like I accidentally changed number of values for this field to 1 - it should be Unlimited. It's working now, thanks everyone. I don't know what I did but I noticed that all (except the ...
2
votes
1answer
33 views

How can I get the parent node of a referenced node?

I have a node called project which contains field building as a referenced item, I used the the hook on building node insert and, having this building id I need to get project id which this building ...
2
votes
4answers
772 views

Media module and views. Cannot make video image linked to node

Using drupal 7.20, Media 7.x-2.0-unstable7, Media Youtube 7.x-2.0-rc2, File Entity 7.x-2.0-unstable7, Entity View Modes latest version. Created new content type called "video", added video field type ...
0
votes
1answer
1k views

Ajaxy entity reference views filter by entity reference view

I have two content types that share a taxonomy (Size). On content type A, I have an "entity reference" to content type B in the form of a checkbox widget. What I want: On the node creation form, ...
1
vote
4answers
844 views

How to change the markup for a field

I'd like to change the output from the field formatter view from the Field API. I'd like a cleaner markup without unnecessary tags. What's the best way to clean up field formatter view output? Many ...
1
vote
3answers
1k views

How to dynamically pass a user field value to jQuery?

I have a notification bar with a counter, it actually prints the user's "notifications" field value (if it's greater than 0): <div id=container> <a href="#" class="activity_link">Activity&...
1
vote
1answer
996 views

Entity query for distinct field

I have an entity line_item with the following fields: id uid (entity reference) product (entity reference) ... I would like to get all distinct products (product ids) for a specific user. I tried ...
5
votes
2answers
932 views

How to create field collection item fields programmatically?

first of all, English is not my native language so sorry if this reads bad. I'm trying to program a field collection with field collection item fields like the code as given by rbruhn here: https://...