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
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
935 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
19 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
34 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
773 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
845 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
998 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://...
0
votes
1answer
833 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 ...
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 ...
1
vote
1answer
832 views

Field widget item form alter for file field

I want to alter field widget item form of a file field with cardinality > 1 so that a new form element is added to each row of the file tables. For example, in the attached image, I want to add ...
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 ...
0
votes
1answer
9 views

Entity wrapper save using db_transaction()?

I am using a db_transaction() for some data updates. I am using some EntityMetadataWrappers, modify some data, then save. The thing is, the wrapper ->save() function doesn't have a parameter for $...
0
votes
1answer
988 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
19 views

Update Entity Reference View based on form field selection

I have a Content Type called Licence which has two fields, field_product and field_billing_cycle. Both are Entity Reference fields, using the select Widget. The product content type has a multi value ...
0
votes
3answers
741 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 ...
0
votes
1answer
25 views

Entity reference and associated data

Assuming I have two distinct entities A and B, with B having an Entity Reference field to A, how can I associate other data (=other fields) with the Entity Reference? For example, assume that A is "...
2
votes
2answers
8k 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
733 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 ...
0
votes
1answer
108 views

Can't render node view mode programmatically

I try to render an HTML data from my node view mode but unfortunately, I have some small progress. I did some searching and modification on the others code Here. I have this now. $nid = 145; $...
-2
votes
2answers
94 views

Search by reference field target ID [closed]

I have a Project content type, which has a reference field to a Contact entity that has a Client bundle. I can get the reference target ID from the node. I want to find the nodes that contain a ...
0
votes
1answer
36 views

Store entity with entity reference field? [closed]

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 ...
5
votes
3answers
1k views

How to set a mini panel to display node fields?

I want to load node fields into a mini panel, but when I do what I think that I need to do, the mini panel (= MP) is invisible (because the fields aren't displayed, I guess). So far I have: Added ...
1
vote
1answer
1k views

How to resolve Catchable fatal error in entity.inc?

Locally (WAMP) I have created a new GIT branch to install Drupal Commerce on my site. Everything went well and I have begun configuring my new shop. But when I decided to pull this branch into my ...
0
votes
2answers
443 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 ...
1
vote
1answer
1k views

How can I retrieve the profile2 fields selected in a custom module?

I am totally new to entities in Drupal. I have used the Profile2 module to add a few profile types. This is displayed in the add/user screen as Customer. After adding the profile type I manage the ...
4
votes
3answers
911 views

Get field_collection values in field template

I have installed field_collection and have a collection called field_contact, each entry of which has a field called field_contact_url I'm trying to customise the display of that field by overriding ...
0
votes
3answers
966 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 ...
2
votes
1answer
820 views

Sort view items by field collection's field value

I added a field collection to Basic page that contains: box title box image box position on page You can add 0 or more field collection's items to every basic page. Every node may contain 0 or more ...
0
votes
3answers
36 views

How can I tell if a config entity hasn’t been saved yet? [closed]

How can I tell if a config entity hasn’t been saved yet?
3
votes
1answer
1k views

Saving values of a multistep form into custom entity fields

I'm building a module that implement a multistep form based on a custom entity. The entity contains fields which are created by the install file. I was able to create the steps and if I print the $...
0
votes
3answers
592 views

How to get vocabularies for an entity reference to a taxonomy?

So I'm having a bit of a difficult time finding out how to get the information I want. I have an entity reference field - call it field_event_type. This is an entity reference to a taxonomy. I am ...
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, ...
0
votes
0answers
42 views

How do I generate a custom content entity bundle?

I created a custom content entity with Drupal console version 1.9.2. Everything is working fine. To use all the configuration and settings of my custom entity type in different bundles, I want ...
2
votes
3answers
1k views

field_type with existing data cannot have its keys changed

our site is throwing up the following error: A list field (field_type) with existing data cannot have its keys changed. in list_field_update_forbid() (line 363 of /modules/field/modules/list/list....
4
votes
2answers
1k views

Upload file and fill in fields in one step; or trigger a rule when a file is uploaded

I want to make use of the Media module and the File entity module to upload files, in particular images, to my site without having to attach them to a node. Solely uploading images works like a charm, ...
19
votes
4answers
20k views

Get only some fields with EntityFieldQuery?

Drupal 7 has very promising ORM-like system of queries with EntityFieldQuery. Currently, I understand how to make selection of nodes, but the result doesn't contain any specific information, like ...
5
votes
1answer
2k views

How do I get a list of bundles?

In Drupal 8 how do I programmatically get a list of bundles for an entity type, for example the list of content types. Specifically, I'm looking for the machine names.
1
vote
1answer
2k views

Why some fields values are getting empty when editing a node?

I have created a content type with 3 field collections and a Text. I've set each to have unlimited values. Data entry for all the fields are OK and when viewing the node all the fields data are ...
62
votes
9answers
122k views

How do I access a field value for an entity (e.g. node) object?

node_load((int) $nid) loads a fully-populated node entity. $node->title->value gets the title, but how do I access field values in Drupal 8?
2
votes
1answer
895 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 ...
3
votes
4answers
3k views

How to use entity form in pop-up window?

I have created a view, and there is one column named "forward to delete". I want to open an entity form in a pop-up after clicking on this link and get the node id of the clicked node so that I can ...
0
votes
2answers
2k views

Entity Reference Selection by View

I have two content types, Location and Offer. The Offer type has an entity reference field that points to one or more Locations. A user of my Merchant role may create Location and Offer nodes. When ...
1
vote
1answer
988 views

Set value for start/end date field labels in hook_form_alter

how can I replace the labels of start/end date for a date field via form_alter? the code below only works for the fieldset. The "to" needs to be removed. $form['field_my_dates']['und']['0']['#title'] ...