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
1answer
677 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 ...
7
votes
3answers
441 views

Safe and elegant way to access nested entities via fields

I've seen a variety of approaches to access entity values in the theming layer. The code below is just a simple example using magic methods. It assumes all values are set - if any part of that returns ...
1
vote
1answer
942 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
33 views

How to render HTML output in hook_ENTITY_TYPE_presave()

Upon node save, I want to take the value of a text field that uses a custom input filter and save the HTML-ified final version (what the input filter renders) in a second field. I have two text ...
1
vote
2answers
997 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
2answers
405 views

Reference View in Entity Reference field

I have a content type that has an entity reference field allowing you to link to other pages and add a custom image, for nice big CTAs. However, it's come to light that some of the links may need to ...
0
votes
1answer
49 views

How to change date format of a custom entity in an update hook?

In would like to display the created date of a custom entity in the "short" format, whereas currently it displays in some default format. This is in a module that is already in, production so I need ...
1
vote
1answer
1k views

Solr index fields not showing a field

I have a field within a field collection that I need indexed. It's not showing up in the /admin/config/search/search_api/index/solr_node_index/fields page. I tried using this to try to add it myself, ...
2
votes
2answers
672 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 ...
10
votes
6answers
15k views

Clean Deleted Field from Database

I have created fields deleted them. Tables for the fields are gone upon deletion, but they are still in field_config and field_config_instance Is there anyway to clean them? Thanks
1
vote
1answer
1k views

Why I cannot get translated entities

I wrote service to get all necessary data for my page. Now I wanted to load them with translations. But whey I try, I got error: InvalidArgumentException: Invalid translation language (id of ...
0
votes
1answer
1k views

What's wrong in my code for setting up entity title in a Computed Field?

I have written inside a Computed Field's Computed Code section the following code: <?php //work if the node is new and there is no value for the field yet if (empty($entity_field[0]['value'])) { ...
0
votes
0answers
15 views

How to access entity id in view of custom entity revisions?

Edit: it has since appeared, but I don't know how I did it! I have created a view of revisions of a custom entity type. I would like to group them by entity ID. But I don't see the entity ID ...
0
votes
2answers
713 views

Pre-populate an Entity Reference when Adding a Node : Based on URL Alias

I am trying to pre-populate an entity reference with a specific game node, when a profile node is added; based on URL of the game the add button is on. The game node I want to reference in profile ...
0
votes
1answer
414 views

How to hide a field when its value is set to zero

I want to hide a field on a node when its value is set to zero using a content type. Here is what I had done so far to achieve my goal. function pay_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { ...
3
votes
1answer
857 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 ...
1
vote
3answers
845 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 ...
5
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
1k views

Custom field widget form - Multiple values

I've create a custom field form widget for an entity reference field. When only one value is allowed it shows a (filtered) select list, but I want to allow user to assign multiple reference values to ...
-1
votes
0answers
24 views

Multi-value field consisting of a select box and input value

I'm trying to figure out how best to store data in Drupal 8. For a language learning site, I have a content type that has Quote as a Text (Formatted, long) field. Now I want to add translations in a ...
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 ...
1
vote
1answer
1k 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
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&...
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 ...
5
votes
2answers
954 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://...
1
vote
4answers
973 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 ...
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, ...
2
votes
1answer
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 ...
1
vote
1answer
37 views

How to alter page content?

Simple thing. I have some page (node). At end it produces some content, i.e. <h1>This is original content</h1> I want to alter it with different content, i.e. <h1>This is changed ...
0
votes
2answers
525 views

How to print the relative url or node id for each referenced node in twig?

I am using paragraphs to render a number of nodes on a page. The nodes are obtained through an entity reference field called 'field_nodeslist' in my cards paragraph type. The cards are then rendered ...
0
votes
3answers
972 views

Organic Groups “create post” content link needed with posting content type specific to group

Organic groups 7.x-2.6 Entity reference prepopulate 7.x-1.5 Hello, I am trying to create custom "create posting" link for my organic groups. Each Organic Group has its own content posting content ...
-3
votes
1answer
42 views

How to get a list of entity types the Drupal 9 way?

I need to get a list of all entity types. EntityManager is deprecated. In Drupal 9 EntityTypeRepository should be used, though I don't see any reference to its being used. How would I use this ...
6
votes
2answers
3k views

How to enable plain text format for body in specific content type

I have one content type, where I want to restrict the body field to plain text only. In Drupal 7, there was an option to set the plain text format explicitly in field configuration; however in Drupal ...
2
votes
2answers
9k views

Right way to create Yes/No boolean fields

I want to add fields in my node which will contain boolean values only : Yes/No. Selecting boolean as field type will cause the field to show up as single check box and in the node edit form I've ...
0
votes
1answer
83 views

Error when translatable

When I save my Custom Entity Type I get an error. I tried several different things. The code looks valid to me. Error: Cannot unset string offsets in Drupal\Core\Field\WidgetBase->extractFormValues(...
2
votes
3answers
3k views

Get parent of an entity reference

I have an entity reference inside node. How can I retrieve the parent node? I tried with the following code, where $node is my entity reference, but it doesn't work. $entity_ids = $query ->...
2
votes
1answer
304 views

Rules send email on entityform submission with current node field content

I have a rule which sends an email on saving an entityform. The entityform appears on several nodes. I would like to 'grab' field content specific to these nodes and include this data in the email ...
0
votes
1answer
762 views

Create and pre-populate a mutiple value field in field collection on new node with ajax call

This question is in the same area as a previous I asked (How to create (& pre-populate) multiple “field collection” fields on an ajax call), but with the extra level of complexity that I'm trying ...
2
votes
4answers
779 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

How to get the count of referenced entity (by views entityreference result)?

For example, a student can register a class. The class node has a date field indicating whether the class is active for registering. The registration node has an entityreference field referencing to ...
0
votes
0answers
29 views

How to make a contributed module's entity type publishable

There's a contributed module called Config Pages and I am trying to make entity it creates revisionable. I attempted to follow instructions from the drupal docs here, But the example no longer works ...
4
votes
1answer
1k views

Adding elements to a field widget

What I need to accomplish is adding a link to a node to field widgets (the node contains the formatted instructions to properly compile the field). The goal is something like this: "What is this?" is ...
0
votes
3answers
765 views

Solution to migrate a field collection

My requirement is to migrate content nodes in xml format to drupal 7 content type fields.The xml contains a node which has to be field collection in drupal.I know how to migrate field which are enity ...
37
votes
5answers
53k 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
25 views

entity:file:undefined" plugin does not exist upload using curl to jsonapi

I'm using php_curl to POST a binary image to my local D8.8 app but it keeps returning a 500 error: The "entity:file:undefined" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\...
3
votes
2answers
4k views

How to translate field collection which has unlimited values?

My configuration: latest dev entity translation and field collection module + patch. I tried: 1. Entity translation is on just for taxonomy term and node, but not for field collection (it triggers ...
0
votes
4answers
2k views

How to run jquery codes before and after ajax call?

I want to create a loading code while the ajax call is not yet complete, AND enable my jquery code after calling the ajax of drupal form. The ajax I'm referring to is the "Add new field/Add more" of ...
0
votes
1answer
536 views

Adding custom field while migrating

I am trying to merging content types while migrating to drupal 8 from drupal 7 and at the same time differentiating them with the taxonomy terms in D8. E.g. The content types from D7 i.e. Article, ...
0
votes
1answer
20 views

Provide unique values from a user profile field in a content type field (How to use DISTINCT in ER View)?

My users profiles contain a field with department name. How can I make the unique values from department available in a select list within a content type field? i.e. Sales, Marketing, IT, etc. (to ...
1
vote
1answer
982 views

Display specific nodes from Views result on specific pages

How do I display specific nodes from a view on specific pages? For example, I create a CCK field ("Display on node id:") for the content type Ads, and put there IDs of content type Basic page where I ...