Skip to main content

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
2 answers
511 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 ...
3 votes
2 answers
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
3 answers
953 views

How can I load entity form for comment?

I want to load entity form for comment entity type. I can load entity form for node (entity type = node and bundle = article). But the entity type = comment and bundle = comment. Here is the code ...
3 votes
4 answers
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 ...
1 vote
1 answer
571 views

Why is an empty field on translated taxonomy term showing default language value?

I have a list of translated taxonomy terms (title, description, link, image). Only some of the translated terms have a value in the link field. Set up as Entity translation My view pulls all fields ...
0 votes
1 answer
38 views

Best practice design route for an estimates table

I need to allow users to store monthly estimates so that they can be later retrieved in our management information system. It would look something like this but with the next 12 months. The first ...
0 votes
1 answer
774 views

Integer user form field with min 11 digits and max 11 digits

I need an integer form field with has a validation of min 11 digits and max 11 digits. In other words; the user has to fill in an 11 digit code. How do i make this field and validation? Update: I ...
0 votes
1 answer
1k views

Delete entity revision does not delete from field_data table

I created a custom entity, I can edit, save, delete, create revisions and revert. I adapted the code from node module to achieve all this and everything works just fine except the revision deletion. ...
0 votes
2 answers
84 views

Deprecated EntityBlock module preventing upgrade

I have a Drupal 9.5 site that I am attempting to composerize and upgrade to Drupal10. I created a Drupal10 site in a local environment, copied the site content over, and installed all the Drupal10 ...
1 vote
1 answer
462 views

Views to Recognize my Custom Entity's One-to-Many Reference

I have a drupal 8 custom entity and have it referencing another custom entity of a different type. It is a one-to-many relationship like a department with assets. It won't recognize the assets ...
0 votes
1 answer
571 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 ...
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
450 views

How to detect if "Show end date" is checked?

Trying to find a way to get the value of the checkbox "Show end date" on a date field on drupal 7. Is it stored somewhere in the database? Can't find it. Its definitely not in the $node object. Any ...
2 votes
2 answers
703 views

Using computed field value

I'm using Commerce module and I have a line item with a computed field that's calculating a date. This field finally shows a date. Then during the checkout process I have a form with a Date field (...
2 votes
2 answers
1k 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 ...
0 votes
1 answer
2k views

Correct way to get field definitions for entity types

I'm still pretty new to D8 so I'm getting to grips with the new way it deals with fields and the OOP way of doing it etc. I've got a hook in my module which I'm trying to add a submit handler to ...
0 votes
1 answer
3k views

Add prefix / suffix to field by using template_preprocess_field

I remember in Drupal 7, this was possible. I need to add some HTML before a field and I don't want to edit it in the Twig file. Is it somehow possible to add prefixes / suffixes by using the ...
1 vote
1 answer
582 views

problems with entity translation insert hook

I'm using the entity_translation_insert() hook to set the value of a field when a node is translated. I can successfully edit the $entity from within the implementation, but how should I save the ...
0 votes
1 answer
977 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
1 answer
70 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
1 answer
1k views

Add menu links to custom generated menu

I am working on a custom Drupal 8 module which generates a menu. Refer Create a new Menu in Drupal 8 programmatically for details. I have the menu now, but when I try to add custom menu links to it, ...
1 vote
2 answers
2k views

How can I see all the places an asset or entity is referenced?

In Drupal 8, I have a requirement from a client that they be able to find a reference of a given asset (file, node, entity, etc) throughout a Drupal site. The ultimate goal is to know that if they ...
0 votes
1 answer
598 views

How to show an Inline Entity Form on a PM page or panel?

I'm trying to include an Inline Entity Form on a panels display (via ctools Page Manager). The Inline Entity Form field is attached to users, and the page in question has the user's context. The ...
2 votes
1 answer
3k views

How can I add a specific action button?

Is there any way to add a specific action button in a view for an entity I've programmatically created? More specifically, I want to make a search of my entity in view and have, beside each result, an ...
1 vote
1 answer
688 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
1 answer
462 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) { ...
0 votes
1 answer
521 views

"Image Upload Button" section remove after click on upload

I am trying to edit users's profile page in Drupal 7. I have an image upload button there, but it remove (hide) after click on upload button . But If i login with admin its working fine, means image ...
2 votes
1 answer
606 views

Change label max length on all field types

The default max length for all labels of all field types is 128. The db can handle 255. So no schema change. How can I change the default max length to 250?
0 votes
1 answer
467 views

Show node body fields for entity reference checkboxes widget?

I need to show the body field of the nodes next to their checkboxes in an entity reference field widget (default is just their node titles). Is there a way to do that without writing a new widget?
8 votes
9 answers
14k views

How do I programmatically delete a reference field value?

I have a multi-valued taxonomy reference field named field_classrooms in a node type. I use below code to delete the value in the field. $node = Drupal\node\Entity\Node::load('1512'); unset($node->...
6 votes
3 answers
3k views

How do I define a computed field equal to the concatenation of two fields of my custom entity?

I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, userID, created, changed. I created it with baseFieldDefinitions. I want to have a computed field ...
0 votes
2 answers
625 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
1 answer
19 views

How to restrict access to GET with JSON:API for specific entity type?

According to the JSON:API docs, you can implement the alterRoutes() method on a route subscriber to restrict access to collections. In a custom module, I have an entity type that should be POST only (...
1 vote
1 answer
577 views

Adding new fields using hook_field_schema_alter()

I have an entity whose field schema is already defined and now I am trying to add couple of fields to it. But I am not sure how to code it up using schema_alter.Below is an example on how I would ...
14 votes
4 answers
10k views

How can I programmatically create a revision for a node?

I have a node object and I need to create revisions for that node programmatically. When I tried as follows it's not working. Instead it's creating new nodes. What am I doing wrong? How can I fix this?...
0 votes
1 answer
26 views

"Route does not exist" in JSON:API for custom entity type

I created a custom entity type using drush generate entity:content. I chose to have bundles, and I added a bundle test_bundle. I can add my custom entities at admin/content as expected. However, when ...
0 votes
0 answers
14 views

In ListBuilder, UUID sometimes shown for anonymous

I created a custom entity using drush generate entity:content. In MyEntityListBuilder.php: /** * {@inheritdoc} */ public function buildRow(EntityInterface $entity): array { $row = []; ...
0 votes
1 answer
614 views

Adding Quick Tabs Programmatically to a node is not working

I'm writing below code in my node--type.tpl.php, but only empty page is loading when i load the node page.Can you please help in knowing my mistake. What i need to add to display quicktab and its ...
7 votes
1 answer
308 views

How to get referencing parent entity when adding entities via Inline Entity Form to set automatic titles?

I have a content type "Parent" and a content type "Child". When adding Parents, the user can add Childs via Inline Entity Form. Child content types have Automatic Entity Label enabled. In that ...
0 votes
1 answer
524 views

Confusing Widget of inline entity form

Inline Entity Form ships with two widgets as Inline entity form - Single value and Inline entity form - Multiple values when I use Inline entity form - Single value, I only get add entity form and ...
1 vote
1 answer
576 views

Custom Field Type is missing in Feeds Importer

I've got a problem with feeds importer. I've created a custom field type, and added a field with this field type to my content. If I try to import data via feeds importer, in mapping, this field is ...
0 votes
4 answers
3k 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 ...
1 vote
2 answers
1k 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 ...
1 vote
1 answer
714 views

How to set body field display programmatically on node type install?

When hook_installing a new custom node type filled with custom fields I call field_create_instance($instance) where I also set the custom fields' display like so: 'display' => array( 'default' =&...
1 vote
1 answer
612 views

How can I conditionally reference an entity?

I would like to have an inline entity reference form that will optionally provide a write-in text form if the entity doesn't already exist. Here's the use case: I want to reference a faculty profile ...
2 votes
2 answers
920 views

Programmatically set the number of Multiple Value CCK fields in node edit form

I have a filefield multi-value CCK field and I want to be able to set the number of values that can be added based on some condition when the user is editing the existing node. Is there a way to ...
2 votes
1 answer
785 views

How to check in a rule if the data from a field collection has changed?

I want to add a rule (using the Rules module) for printing a message after changing a field in a field collection. The field collection consists of the following three fields: Reference to Version (...
1 vote
2 answers
861 views

Views, Pathauto and contextual filters

My question is rather simple, but I didn't manage to find anything that can help. Summary of my setup : Pathauto Views Entity Reference So I have various custom content types, which I want to ...
1 vote
1 answer
725 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 ...
0 votes
2 answers
1k views

Inline entity form prepopulate

I have a content-type A which has a reference field to another content-type B. When creating/editing content with type A I let the user create/edit content of type B using the inline_entity_form ...

1
2 3 4 5
175