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
2answers
598 views

How do I perform outstanding entity updates after 8.7?

I have just tested the update to 8.7.1 (from 8.6.x) which includes the removal of the old automatic entity update functionality, which means drush entup no longer works. As far as I understand the ...
2
votes
1answer
41 views

How do I add a view mode to a simple custom entity?

I have created a super-simple drupal 8 custom entity. We now need a custom view mode for this entity. What do I need to add to my definition to make my entity appear as an option on the 'Add View ...
1
vote
1answer
598 views

Entity reference field pointing to a Configuration Entity [closed]

I develop a custom statistics module to log all node views of a chosen bundles, file downloads and the keywords used to filter a view. Then I build my Entity Log with a user reference (who does the ...
0
votes
0answers
12 views

How to select specific entities from a view made as an REST export

I have made a REST export from a view, which is fine when I set it up to SHOW "FIELDS", which I select and define myself. My issue is if I set it up to show: "ENTITY", then I get a HUGE result set ...
-1
votes
1answer
25 views

How to add multiple values to file/image fields while creating node programmatically?

I have multiple images coming dynamically in array. But while adding those images to node only last file get attached in field and other images only saved in file directory. I have tried everything ...
2
votes
1answer
341 views

Making File Field description required

My users always skip adding the "description" to the file field because they can. I tried implementing the code posted here: How do I make Drupal File Description Field Required? (and thank you) -- ...
1
vote
1answer
1k views

Programmatically create a paragraph entity reference field

I need to create a config page, that is able to add social media information ( name and icon ), the user must be able to add as many social medias as it wants. To do so, I'we created a paragraph with ...
1
vote
2answers
825 views

Set a boolean (single on/off checkbox) value while creating a node

I am creating a node (in Drupal 8) with the following code. use \Drupal\node\Entity\Node; $node = Node::create([ 'type' => 'calendar_data', 'title' => 'testing finaly ...
-1
votes
0answers
23 views

How to create a custom token from the parent entity of a comment for the Message module?

I have a site with Drupal, as well as the modules "Message" and "Token". I created a custom module based on the module "Message example". It is possible to create comments on several types of ...
0
votes
2answers
154 views

Custom Entity: define a view in entity reference field

I defined a custom entity and for a entity reference field I want to set the view reference widget and a view/ display to be used instead of an autocomplete. I tried many different settings - nothing ...
0
votes
1answer
380 views

Link field title from entity/route

I have a Drupal link field configured to allow both internal and external links and have the title field enabled, but optional. I want users to be able to reference internal entities without having ...
-1
votes
0answers
39 views

How to create a custom token for the Message module?

I have a site with Drupal, as well as the modules "Message" and "Token". I created a custom module based on the module "Message example". I created for entities, a display mode called ...
0
votes
1answer
26 views

Node Reference Argument In loadByProperties() while Creating API

I have a custom module which generates an API, I want the API to filter content based on a node reference field. How do I pass the field field_author(Entity Reference from another content type) field ...
0
votes
2answers
426 views

How to hide field if blank

I have a view created which has a column 'Price'. I also I have another column 'Special Price' in the same view, but 'exclude from display' is selected. In views, click the price field > rewrite ...
1
vote
1answer
362 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 ...
1
vote
1answer
343 views

Get array length of a multiple fields of a node content type

I'm developing a site with Drupal 8. I made a custom content type, with a lot of fields; in particular I have a field called field_categoria_del_libro_presen that is linked to a taxonomy term. It's ...
5
votes
2answers
3k views

How do I load a form with a specific form display (form mode)?

On a custom page I'm trying to load an user edit form with a specific form display. I'm able to load the form however I can't figure out how to load the form with the specific display. This is what I ...
1
vote
2answers
373 views

Field available only when a value from a Hierarchical Select is chosen

I am using a Hierarchical Select that enables a user to first select a continent ( first select ) and then a country ( second select ) I wish however to enable a field ( text ) only when a user ...
1
vote
1answer
433 views

Conditional Fields with multiple conditions

I am using Conditional Fields module. I need some guidance when setting dependencies for multiple fields (accepting unlimited values). Here is the situation: In my entity form I have two fields: ...
0
votes
1answer
422 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, ...
1
vote
1answer
384 views

How do I access the first value of a multiple value text field using replacement patters inside a rule?

For example, lets say I have a list of objects each stored as separate values of a text field. How would I access the individual values? I have tried using delta and I have tried using entity token ...
0
votes
1answer
336 views

403 Error on AJAX Request in add new item (collection field)

I have normal content type which has 12 collection fields each field has unlimited value when i try to click add new item on any field it gives me ajax error An AJAX HTTP error occurred. HTTP Result ...
5
votes
4answers
3k views

Using hook_entity_base_field_info for adding new field

Is it fine to implement hook_entity_base_field_info to add a new field to the advanced group in each node? If so, how is the storage handled by default for base fields? Should I need to create a ...
0
votes
1answer
428 views

Remove field attributes from form or custom form using hook_form

How to remove the field attributes from form in hook_form_alter. like <input type="text" class="form-text required" maxlength="255" size="60" value="" name="title" id="edit-title"> EX: ...
0
votes
1answer
346 views

How do I use Hook_update_N to update an FieldConfigStorage?

function some_config_update_8101(){ if ( !FieldConfig::load('image_byline') ){ $config_path = drupal_get_path('module', 'some_config') . '/config/install/field.field.node.main_image....
14
votes
2answers
7k views

What is the purpose of drush entity-updates?

After updating Drupal 8 modules, I have been warned on the Drupal 8 status page that: Entity/field definitions: The following changes were detected in the entity type and field definitions. ...
1
vote
1answer
2k views

How to get the list of all entity reference fields and their params?

I'm trying to build a new widget for the entity reference module. (nested checkboxes = tree according to entity references between nodes) The only answer I'm looking for is : "How to get the list of ...
2
votes
4answers
2k views

How to add a database index to a base field

Goal: Add a database index to a 'created' field. Given: There is a custom entity with a base field created. The field is stored the entity table. Field source code of the created field: $fields['...
3
votes
2answers
682 views

How to use RegexConstraint with field?

I'm defining a base field for my custom content entity: $fields['machine_name'] = BaseFieldDefinition::create('string') ->setLabel(t('Machine name')) ->addConstraint('UniqueField') ->...
5
votes
3answers
508 views

How do I create an instance of an entity with all its fields attached?

I am trying to create an instance of 'commerce_customer_profile' entity with all the extra fields of the customers address. I am doing this inside a FeedsProcessor that will import users and their ...
1
vote
0answers
27 views

Define a default image when using image as base field in custom entity

I defined a custom entity type with an image base field. Now I want to have a default image which seems to be quite tricky: when I define a default image on a field api field and export the configs I ...
0
votes
1answer
402 views

How to get menu tree from a node to build a customize breadcrumb?

I would like to build a custom breadcrumb based on node relation from entity reference. For example there is a book node that has menu hierarchy: Book |-chapter 1 |--sub chapter 1.1 |---sub sub ...
7
votes
2answers
3k views

getvalue() of multiple values field return only the first value

I added a new field in the field manage user page. This is a sample integer multivalue field. (we can enter several integer) I edited the profile of the admin user. I added (and save) some values in ...
1
vote
1answer
389 views

Pass data to hook_entity_insert

How can I pass data to hook_entity_insert() given that the arguments it takes are fixed? I'm writing to the database during entity save, and need to be able to pass some data in this hook.
0
votes
1answer
783 views

Query - Content type [closed]

I want to get all created content of some content type by query. By now I can access nodes by their ID. $MyNode = \Drupal\node\Entity\Node::load(1) I tried some query, but none of them worked for ...
0
votes
0answers
22 views

Listing two different custom entity types in one view

We defined two entity types, questions and answers. They are related to each other but we will need a view listing all questions and answers in order of title or created date for example. When you ...
4
votes
2answers
912 views

Difference between a bundle and a content type

Can somebody explain to me the difference between a content type and a bundle? Is the latter just a bundle for the entity node?
0
votes
1answer
480 views

Show/hide fields bij adding content based on checkbox

Is there a way to hide a specific or specifics fields in Drupal when you create content until you checked a checkbox? Now it looks like this: I need something like this: But I need some checkboxes ...
2
votes
1answer
30 views

Is there a way to get the max size of a varchar textfield?

I have an entity with a textfield created using the core Fields feature that looks like this when I inspect the type of the field table in the database varchar(40). I want to be able to determine max ...
1
vote
2answers
297 views

Find and display most recent referencing entities

I have 2 different node types. The first one describes a factory and the second one describes a measurement of the water inside the factory. The measurement content type has an Entity Reference field ...
0
votes
1answer
356 views

How can I query and order nodes with multiple date field values within a specific range?

I'm trying to get nodes that have date fields (multiple instances in some cases) and display them sorted ascending by start time for a given date. For illustrative purposes, here are some events and ...
41
votes
13answers
27k views

How do I remove a configuration object from the active configuration?

I'm writing a custom module for Drupal 8. It defines a field storage configuration object, in a file called modules/mymod/config/install/field.storage.bloom_stem.bs_twitter_ac.yml. The problem is ...
3
votes
3answers
5k views

How do I delete custom entity instances?

I've create a custom entity content with Drupal console, drupal generate:entity:content Now I want delete (remove) it completely, how can I achieve it with drupal console or drush ? my drupal ...
5
votes
1answer
2k views

How do I get a list of bundles for an entity type?

In Drupal 8 how do I programmatically get a list of bundles for an entity type, i.e. a list of content types or node bundles. Specifically I'm looking for bundle machine names.
0
votes
0answers
35 views

Updating custom entity field

I have a custom entity and wish to increase size of a varchar field. This gives helpful input: https://www.drupal.org/docs/8/api/update-api/updating-database-schema-andor-data-in-drupal-8 I added ...
0
votes
1answer
417 views

Entity reference of a menu link gives Restricted access instead of the real data

I am trying to create an entity reference of a "menu link", but instead of having the menu link name I got "- Restricted access -". It seems to be the same problem with wysiwyg profile. I'm using the ...
1
vote
2answers
2k views

Migrating link fields to Drupal 8

I am trying to migrate a link field field_url from a Drupal 7 site to my Drupal 8 one. The link field is compound, it has a title and a url value. In my process plugin I am selecting the right values (...
1
vote
3answers
295 views

Print multiple files field links, descriptions and file extensions in Twig

I have a content type with a field field_file_attachment that allows uploading multiple files with txt, pdf, gif and img extensions. I would like to get links, descriptions and extensions of all ...
4
votes
1answer
105 views

Custom theme: variable not made available in menu template

I've created a custom theme, let's call it "mytheme" in the examples, with the "classy" theme as base. I use several templates, one is menu--account.html.twig, it's an override I made of the classy ...
1
vote
2answers
56 views

How can I leave Subject as blank when fill nothing in the subject field of a comment?

When we fill nothing in the subject field of comment, drupal will use the comment body as the value of subject. See the code in CommentForm::buildEntity // Validate the comment's subject. If not ...