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
15 votes
4 answers
46k views

How to get paragraph field values?

I'd like to create a product list in drupal and send it in a webservice. For this I created an entity type with paragraphs for each product. How can I load the paragraph and access its fields? Until ...
11 votes
3 answers
6k views

Set timestamp field default value empty

I have created field type "Timestamp" in my Drupal 8 node. Field is not required. In field settings default value, there is HTML 5 datetime picker, in which you can select default date/time or leave ...
1 vote
1 answer
412 views

Programmatically format integer field display

I am trying to programmatically format how an integer field displays. So far I have only been able to produce "1.00", and I am trying to get it like so: x.xx.x. The content type is "Project" and the ...
0 votes
0 answers
47 views

Drupal 10 - Get the value of a custom user field

i spent my day on that... how to, in Drupal 10, get the value of a custom field added in the user profile. i read and test everything found on google, just like that (from different thread/forum): $...
14 votes
10 answers
18k views

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

I'm getting the following error on my Drupal 8 configuration page. Entity/field definitions Mismatched entity and/or field definitions The following changes were detected in the entity type and field ...
0 votes
0 answers
47 views

Why would Manage Display break when the content type machine name is a number?

Drupal 10.1.6 PHP 8.2.5 I am not sure how long ago it started, I just noticed it about a week ago. It only happens when the machine_name of the content type is numeric. When I go to /admin/structure/...
1 vote
1 answer
735 views

Date with an option for end date being either a date or "ongoing"

I have a content type that contains relevant information of a project. It should hold the projects start date and the end date OR the status "ongoing". How do I make this happen? With the date field ...
0 votes
1 answer
426 views

Assign textfield to each checked option in a checkboxes field

Lets say I have a checkboxes field and when I check one of the options, I would like a textfield to appear so I can assign a number (quantity) to it. Every option I check would have its own textfield. ...
1 vote
1 answer
1k views

Schema.org itemprop="url" inside anchor object (link)

I'm trying to use the preprocess function to change the default outpot of links <a href> to include Schema.org's itemprop="url" inside the anchor object, as well as adding a <span itemprop="...
1 vote
2 answers
2k 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 ...
1 vote
2 answers
785 views

Dynamically Theme Boolean Fields

I am trying to dynamically display boolean fields into columns based on their value. So for instance these 10 boolean fields on my node, if marked 1, I want it to theme it so that they show up in a ...
0 votes
1 answer
1k views

BaseFieldDefinition setDisplayOptions ... type = 'string_textfield' ... unable to set default placeholder or size?

I'm unable to get a default placeholder and/or size to register against a BaseFieldDefinition. I'm trying something like: $fields['company_name'] = BaseFieldDefinition::create('string') ->...
0 votes
2 answers
482 views

Call to undefined function entity_create()

i try to include a node creation form by a field attach form. So i try to load the entity of a custom content type created by the back-office with is called 'friterie'. But when i call the ...
0 votes
1 answer
809 views

Accessing Content: Path field within views_view_unformatted TWIG template

I have a view that has the fields: Content: ID, Content: Title and Content: Path. In my views-view-module.html.twig file I can access the fields via the following: {{ item['#row']._entity.id }} {{ ...
0 votes
2 answers
2k views

How can I pass variables from a view template to a node template?

I have a view showing the nodes of a content type which has reference entity fields to another content type. I am trying to iterate through this view with templates. If I choose to show nodes for my ...
2 votes
1 answer
631 views

autofill from taxonomy term fields

I'm trying to connect a field of a taxonomy term to a field in a content type, something like this: Auto-Fill from on content type to another I tried this on a node and it's working, but now I have ...
3 votes
1 answer
465 views

Altering ImageField Widget with FUpload enabled

I need to alter the ImageField Widget so that I can add some fields other than the Description, Alt and Title fields. I'm able to do this when I select the file field widget type as Image Uplaod, but ...
0 votes
1 answer
109 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 $...
1 vote
1 answer
635 views

views with multiple contextual filters - should return data only when both or any one filter is present

Views of content is having two contextual filter. For some reason node object is available to views so it is passing through url's 7th argument. 1.Content: Has taxonomy term ID Configuration: Php ...
3 votes
2 answers
993 views

Inline entity form shows a content type select list

I am using Inline entity form for a non-commerce project. The settings are:Widget:multiple values,Node:Allow users to add existing content. Mode:Views:Filter by Entity reference view.So I have created ...
3 votes
1 answer
2k views

Entity table not created [closed]

I use drupal:generate:entity to generate my entity but it doesn't create the database table. Then it result an error when i tried to access to my entity list page. I tried to launch www.mysite.com/...
2 votes
1 answer
450 views

How to populate a node reference field that has multiple values?

I'm using the rules to create a new node upon changing the current node publishing status to published. And populate some field based on the updated node field. Im trying to populate a node reference ...
0 votes
1 answer
799 views

custom field - How to get saved term selected for entity_autocomplete

I've looked all over, and for my level of understanding, I can't figure out how to get the stored value of an entity autocomplete field targeting taxonomy term type. I thought I could do something ...
0 votes
3 answers
607 views

how to automatically create other entities when creating an entity

I have 4 entity types. All types have a relation to each other. For now let's call them A, B, C and D. How can I allow a user (let's say userA) to create an entity of type A so that entities for B, C ...
0 votes
1 answer
1k views

Creating paragraph entities and adding to a node

I am using the Paragraph module in and I need to programmatically create paragraph entities and attach them to nodes. Using the following code in a for-loop: $paragraph = new ParagraphsItemEntity(...
8 votes
1 answer
3k views

Add Expression for Entity Query

I've been working with the entityQuery to query the db and get an array of filtered nids however I need to add an expression to my query. I've checked the Query class and found a protected sqlQuery ...
1 vote
1 answer
893 views

Views math expression or Computed field to find date difference in views

I have two content type, Bill (Type1) and Cash Receipts (Type2), Type2 referencing Type1 when cash is received. In Type1 I have date field called (Bill Issue date), and Type2 I have date field cash ...
0 votes
1 answer
466 views

Save selected values from a checkbox into a field

I've the next form. $query = "SELECT name, tid FROM taxonomy_term_data WHERE vid=2 AND language = '$language_url';"; $result = db_query($query); foreach ($result as $row2) { $options2[$...
0 votes
1 answer
446 views

Remove order from Field Collection set in form

I am using the Field Collection and Field Collection Fieldset modules to group a set of elements in my form. But what i see in the form is an Order column for the fieldset items, which i would like to ...
0 votes
1 answer
415 views

Why is an entity reference view field only showing one view result?

I have a form field on a node create form that is an entity reference, referencing a view that displays all of the appropriate results. The view displays users with a relationship to a content field ...
-3 votes
1 answer
79 views

How to programmatically create a redirect and then get the redirect ID of newly created redirect? [closed]

I am trying to create a redirect programmatically, then reference the ID of that redirect from a node. I use hook node in my module with the following code to create a redirect. use Drupal\redirect\...
2 votes
1 answer
2k views

Migrate row data into 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: - ...
0 votes
2 answers
877 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 ...
4 votes
3 answers
825 views

Media library widget: Table instead of grid?

Background I have a multiple-value entity reference field with target type = media. It is used for "document" media, so mostly pdf files. I am using the "Media library" widget ...
1 vote
1 answer
521 views

Referencing parent entity

I've just started with Drupal and I'm trying to create the following URL structure with PathAuto and Entity Reference: Category A -> Category B -> Category C Resulting in category_a/category_b/...
0 votes
1 answer
750 views

How can I dynamically change the display format?

I have an entityreference field. I want to change the 'Format' under 'Manage Display' from 'Rendered Entity' to 'Label' based on custom logic. Basically, what I'm doing is, if there isn't an image in ...
0 votes
2 answers
508 views

Computed field that displays the full username of the author

I am using a computed field and I want to display the field_first_name and field_last_name, which are properties of the user that created that node. I have been trying things, but it seems like $...
0 votes
1 answer
822 views

Entity reference field definition to auto create entities

I have a field definition set up like below. I want Drupal to do all the heavy lifting for me, so my definitions are minimal and rely on Drupal defaults: $fields[$field] = BaseFieldDefinition::...
1 vote
1 answer
3k 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 ...
1 vote
1 answer
440 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 ...
1 vote
1 answer
478 views

default value imagefield -> get from field collection item

I've got a contenttype "gallery" with an imagefield "thumbnail", used in listviews oder teaserviews. This contenttype also has a field collection with "image", "title" and "description". So what would ...
3 votes
1 answer
762 views

Webform description allowing HTML

I'd like to allow HTML in my webform field descriptions. I don't need an editor of some sorts; just the basics like and tags and stuff. How can I edit my webform to allow these tags in the ...
1 vote
2 answers
477 views

How do I use print to generate a PDF of all entities referencing a specific node?

I'm trying to use the Print module to generate pdf's and epubs of the stories on my site. However, I need to get Print to generate these files from the story page and then generate the pdf with ALL ...
4 votes
1 answer
687 views

EntityFieldQuery with Workflow

I need to filter an EntityFieldQuery with a given workflow state, let's say workflow it is state 21 (sid = 21). Below, the query I am using $query_formularios_completos = new EntityFieldQuery(); $...
1 vote
1 answer
1k views

Inline entity form ajax

I am trying to update some field options in an inline entity form with ajax. This should happen, when someone selects a value in an other field. I already have some code which "works", but the ...
1 vote
1 answer
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 ...
0 votes
1 answer
21 views

Prepopulating a drop-down select box that references another entity

I have a node create form for content type "space" so that the URL looks like https://.../node/add/space. In this page, there is a form with a drop-down select that corresponds to an entity ...
0 votes
0 answers
56 views

How can I get the error message when a user account has not been successfully saved?

I'm trying to build a rest API to provide my mobile team to register a user using mobile app. I'm using www.example.com/entity/user for rest API as POST. I'm able to create the user, but in some cases,...
1 vote
2 answers
497 views

create a custom field schema

When I create a new field programmatically, drupal create a default schema for my being added and for each new field added is create a new database schema. I noticed that the columns always have the ...
1 vote
1 answer
757 views

Accordion is not working in field group module

I have configured the Field group module for Drupal 8 to manage the display of my node into accordion. I added an accordion wrapper, and assigned an accordion item into it. Lastly, added the fields ...

1
2 3 4 5
175