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
514 views

How to get parent node values on inline entity form hook alter?

I am using inline entity forms to create a paragraph in a node form. When I add a node I want the title of the node form to be copied to the paragraph when I click on "Add paragraph". I use ...
2
votes
3answers
2k views

How can I give a list_string BaseFieldDefinition in a content entity a default starting value?

I have an entity with a list_string field in my content entity that outputs to the entity form as a list of checkboxes. IE: $fields['colors'] = BaseFieldDefinition::create("list_string") ->...
0
votes
2answers
40 views

Entity create access based on a custom field

Is there a way to allow/prevent users to create a new entity based on an entity field? Because the checkCreateAccess() / hook_entity_create_access() function is not receiving the actual entity as a ...
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
444 views

How to set “Entity has Field” when the Rules Event is unrelated to the entity?

In Rules, I am trying to update/calculate a field in the User's account upon completion of a commerce payment. The condition data selector obviously only wants to populate commerce related fields, ...
0
votes
2answers
2k views

creating child terms from a parent using fields

For a project i would like to achieve the following: Using 2 fields in a content type field_parent = reference to term This field references to vocabulary 'parent terms' I have a second field ...
1
vote
2answers
1k views

how to render a node field of a referenced node on the node form

I'm using Display Suite to show a referenced node inside another node in the default display. But when I edit this node that has the entity reference field on it, it shows me the reference field and I'...
1
vote
1answer
464 views

How to use the same EntityListBuilder for entity A and an extended version B

I have used the content entity example coming from the example project. This example define a Contact entity. Next I have extended this Contact class in an Artist class with some added fields (let ...
1
vote
2answers
825 views

Feeds: Is it possible to set a unique field other than the title field?

I'm trying to create a feed importer that uses a unique ID that is NOT necessarily in the title field of the content type. For example, were I using the feeds importer to import a list of contacts, I'...
0
votes
1answer
397 views

Adding value to multi-delta textfield programmatically

I have a phone field in a form, which is just a textfield with its default widget. I'm trying (and failing) to add values to this field programmatically through ajax calls. I have an ajax call ...
1
vote
2answers
3k views

“Uncaught TypeError: Cannot read property 'getAttribute' of undefined”

There are some posts about this error for Drupal 7, but I'm using Drupal 8.1 and those solutions don't work for D8. I tried this patch (coded for D7) and doesn't work. The effect of the error is ...
-1
votes
1answer
50 views

Is it possible to get the node ID of the node that will be created?

Trying to pass some information to third party API, every time a new node is created. So far I have managed to identify the node insert/create when a node is created in hook_node_presave(). Done it ...
0
votes
2answers
362 views

Linked entity references in a content type

I am unsure if this is possible in Drupal 7, but here is my problem: I have 3 content types, A, B and C. B and C refer to A through a field field_A (entity reference). C refer to B through a field ...
1
vote
1answer
2k views

Entity Reference View Widget problem with add selective

I am using a content type which uses a field as "Views" Entity Reference View Widget. When I click "add selective" or "add .. and close" in form of this widget, it's just redirect to http://localhost/...
0
votes
1answer
926 views

Calendar widget link to list a day's events

I am using the Calendar module to manage an events calendar on a new site. Currently when you click on a day in the widget it takes the user to the calendar page that shows a small list of the titles. ...
2
votes
2answers
1k views

Related Content View with multiple Entity Reference Fields

I am trying to create a View to display related content based on shared taxonomy terms from multiple vocabularies. For example: I have two content types called Car and Parts. I have two ...
1
vote
1answer
38 views

How do I limit a normalizer to a given class or interface?

I'm creating a custom normalizer for node entities. I want to restrict the normalizer to normalize Node entities only. It seems like there are two ways this can be done: protected $...
1
vote
2answers
2k views

Entity form with pre-populated entity reference from URL

I have two entities which are in a parent/child relationship. Now I want to add a operations link in the parent's list view so that I can show the child's entity form with the reference to the parent ...
3
votes
1answer
808 views

How to change the View Mode based on theme?

I am using the ThemeKey module to change the theme for mobile users. I have a custom View Mode called Mobile to display different content. I would like to have when my mobile theme is loaded for the ...
1
vote
1answer
25 views

How can I remove the “This translation is published” checkbox?

In my custom entity module I have already defined a status checkbox to determine the entities status. What I noticed is when I enable show_revisions_ui in the annotation and have the entity setup to ...
2
votes
2answers
2k views

How to add UniqueField constraint on integer field?

The title basically says it all. I have the following field definition in an Entity class: $fields['code'] = BaseFieldDefinition::create('integer') ->setLabel(t('unique code')) -&...
1
vote
2answers
68 views

How to Allowed Options for BaseFieldDefinition on Custom Entity

I'm trying to access the allowed options on a custom entity's field that I created. (see code below) Is there a way to access this? One field I would like to access, for example, is... $fields['...
0
votes
2answers
1k views

How to output custom field of Content type in page.tpl.php?

I want to display a custom field which I created in my custom Drupal theme. The field I created called "Startnummer" so the machine name of the field (I didn't change it) was created as "...
-2
votes
2answers
58 views

How to get all the entity details which are using specific media?

I have a image "sample.jpg" (In media library) and I used this image in multiple custom blocks of different block types. Now I need an information of all the custom blocks which are using "sample.jpg"...
1
vote
1answer
419 views

hook_inline_entity_form_table_fields_alter add custom field

Need some help with Inline Entity Form hook function hook_inline_entity_form_table_fields_alter. I'm trying to add columns to the table that is visible when editing a specific node. I have been able ...
1
vote
1answer
2k views

How to add / update a field collection without updating parent node/entity?

I needed to to add / update field collections to node entities without updating the node entities. I tried two ways listed in https://www.drupal.org/node/1842304 and http://alexrayu.com/blog/...
2
votes
2answers
62 views

Custom content entity: can't hide translation details in edit form

I've created a multi-lingual custom content entity using Drupal Console. The basic stuff with editing/viewing works fine, also multi-lingual. But for some reason, I can't hide the "Translation" ...
1
vote
2answers
2k views

How to access taxonomy term field?

I added two fields to my vocabulary terms field management. How do I get these values? There is no fields like color or Image in my Taxonomy Term vocabulary dump. How does Drupal 8 store these ...
0
votes
2answers
1k views

Render Date Range on node template

I'm trying to render both start and end date on a node template in Drupal 8 from the Date range field from the content type. I've tried multiple ways to no avail. -- Only shows start date -- {{ kint(...
0
votes
1answer
391 views

SQL query to access a field collection's data? At them moment, I'm only getting field_collection_item returned

In the below example, I am trying to return the value of a field from all the field collections in the database but only get field_collection_item. This example is just the most basic field collection ...
-1
votes
1answer
55 views

Custom Content Entity Bundles - How to override class methods?

I created a custom content entity type and a bundle of this entity type. The custom content entity is presented as PHP class; the entity bundle is defined in a configuration file. I created the ...
2
votes
2answers
1k views

Updating a module field schema

I'm currently working on a project created by someone else. I have a textfield called "city". Currently the maximum limit is 255 characters. I want to update the maximum character to be 100. Looking ...
0
votes
2answers
399 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). ...
2
votes
1answer
2k views

What may cause Column not found (nid) in on clause?

I'm using Drupal 7.14 and Entity API and Reference 1.0-rc3. And I'm also using i18n, entityreference (not References) and field_sql_storage. I get this error when saving a node that has some custom ...
1
vote
1answer
348 views

field_info_field: how to define the content type name?

I defined several content type. In a module, I need to get the list of fields for this content type. I did the following: $fields = array(); $content_type = 'indicatorsheet_page'; $instances = ...
6
votes
7answers
12k views

How do I enable the WYSIWYG editor on fields?

I added couple of Text fields on a content type in Drupal; however, only the in-built "body" fields is WYSIWYG editor enabled. I am using FCKEditor as the WYSIWYG editor (installed under the Wysiwyg ...
2
votes
3answers
976 views

How to count entity references from same field in different entity types?

I have three entity types: Company Team (has field_company which is an entity reference to Company) Employee (also has field_company, and field_team which is an optional entity reference to Team) ...
1
vote
1answer
3k views

Render entity reference field with link in node template

I have a content type with an entity reference field to select a user. Now I would like to render this field in the node template so that the field links to the user profile. I set the format of the ...
2
votes
1answer
347 views

Allow node author to assign edit rights for other users

Use case: user X creates a node and wants to give user Y the ability to edit the node as well. Think page administrators on Facebook. An Entity Reference field can be used to allow the node author to ...
0
votes
3answers
812 views

How can I change the default system message shown on form submission

I've created a business card request form as an EntityForm and am scratching my head trying to figure out where in the module i can find the line - ( " The submission has been saved " ) . This ...
-2
votes
1answer
43 views

How to get all values of particular custom field of user entity using EnitityQuery?

I have added one custom field to user entity called as "customer_no". On User Registration Form, I want to check whether customer_no already exists. For that, now I want to Fetch all user's values ...
19
votes
7answers
13k views

fast saving single field value

I've got around 70k nodes of specified type on my site. I need to run an update on them. Some operations and setting one field to desired value. node_save is really slow and it causes crashes (too ...
0
votes
0answers
44 views

Custom form throws 'Cannot unset string offsets' error

I'm trying to build a form for my custom entity and so far the form is looking pretty good. However, when I press the Save button I get this error: The website encountered an unexpected error. Please ...
0
votes
1answer
714 views

How to filter entities in View by all of their taxonomy term reference fields?

Let's say I have a custom entity that has two taxonomy reference fields: categories and tags. And I want to display all entities that have taxonomy term with id 1. The term is a dynamic value(...
0
votes
1answer
845 views

Taxonomy terms with conditional field

50 terms and each term needs to have radiobuttons or "other". Food - o in price - o extra price Drinks - o in price - o extra price WiFi - o in price - o extra price So "in price" and "extra price"...
0
votes
1answer
48 views

Set taxonomy field on node creation [closed]

I have a node type 'blog_entry' that uses a taxonomy reference (tags). The tags are created if they don't already exist, i.e. the reference field uses the option 'Create referenced entities if they ...
1
vote
1answer
485 views

Deleting field revisions directly from the database

With full recognition that this is not considered a best practice (and is generally considered a worst practice) does anyone know if it is safe to delete field revisions directly from the DB via a ...
1
vote
2answers
445 views

Entity Reference and Views to allow a nested structure

I'm trying to implement a nested structure in such a way as to get a table (within a view?) similar to this: Parent Child Grandchild Age Sex John ...
0
votes
1answer
349 views

How can I use tokens for Addressfield values without using Addressfield_tokens?

I would like to use the Town/ City field as a token for Pathauto. I thought the Addressfield_tokens module was perfect for this, but Entity Tokens breaks Pathauto's patterns control panel; the issue ...
2
votes
1answer
118 views

Entity field query condition to match multi-value field

Using EFQ, I want to add a fieldCondition that has to match both values in a multi-value field (fixed at two values). The following doesn't seem to work: $query = new EntityFieldQuery(); $query->...