Questions tagged [entities]

Nodes, comments, taxonomy terms, and users, using the terminology used since Drupal 7, are generally called "entities."

Filter by
Sorted by
Tagged with
0
votes
0answers
14 views

Setting default value to custom fields in menu items

I created a custom boolean field in my menu item using this hook_entity_base_field_info function Mymodule_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { if ($...
1
vote
1answer
500 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 ...
3
votes
1answer
469 views

Entity Reference to fields

I'm using the Entity Reference module to relate different unique, particular pieces of equipment (identified by unique serial numbers) to different orders. Equipment and orders are content types. On ...
1
vote
1answer
945 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="...
0
votes
1answer
566 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. ...
2
votes
1answer
489 views

Adding confirm email field to entityform

I am using email field module and entityform for a simple contact form on a Drupal 7 install. I need to add an extra field where the user re-enters their email address (no copy and paste) to prevent ...
1
vote
1answer
342 views

How to edit and delete entityform submissions?

I'm using entityform for particular submission. I set the rule When submitting the entityform, its stored in particular content type. Its works well. But when edit and delete the particular ...
1
vote
1answer
344 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 ...
5
votes
3answers
2k 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 ...
1
vote
1answer
505 views

Alter label with token

I am trying to build a questionnaire that simply replaces (alters) the label of a list-field. I´m doing so by replacing a token from views (embed) and using a hook_alter_form function in an separate ...
2
votes
1answer
932 views

How to check if an entity is referenced before deleting?

Is there a module or a way to use Rules to make sure that a parent node isn't referenced by a child node before deleting the parent? In my case the children require a parent to be created. However ...
0
votes
1answer
537 views

preprocess_field() not working - what am I doing wrong?

I am trying to use mytheme_preprocess_field() to alter how a field is displayed. Here is the code I added to my theme's template.php: function creative_responsive_theme_preprocess_field(&$vars) { ...
1
vote
1answer
663 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, ...
2
votes
1answer
533 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
1answer
3k views

Preprocess image: how to get parent entity?

I'm using responsive images (single img tag with srcset and sizes attributes). My content editors can manipulate the displayed size of the image with a custom field on a shared parent entity. ...
2
votes
2answers
500 views

How do I access an Entity Reference's field values?

I have 2 content types. BaseContent: Field1: Title Field2: ID# RelatedContent: Field1: [Entity reference to a BaseContent] Field2: **[Automatically insert the value of the referenced BaseContent ...
0
votes
1answer
530 views

Config Entity list_builder controller path throws Route Does Not Exist error

I have created a custom config entity, which declares a list_builder controller to return a list of the created entities. Before creating a config entity, it renders as expected. Once I create a ...
0
votes
1answer
491 views

Views Bulk Operations with Field Collection Item tokens

I am trying to modify the values of one field in all instances of a field collection type. I have a view listing all field collection items, that I want and an operation field with modify entity. ...
3
votes
1answer
548 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
2answers
543 views

Programmatically embed fields of one content type in the create/edit form of another content type and store all

I have drupal 6.x. How to programmatically (with a custom module) embed fields of one content type (content type X) in the create/edit form of another content type (content type Y) and store all ...
0
votes
1answer
532 views

How to setup multiple currency drop down

I have basic content type setup (No commerce or ubercart) which display price as a text field and that value has been used in 5 computed fields. Now i like to make that price field in drop down ...
1
vote
2answers
292 views

How to get the File Description on a custom field formatter?

Greetings to all of you. This is my first question posted around here, so any suggestions are welcome on improving how to better formulate questions. Into the matter. I have the following code in a ...
1
vote
2answers
540 views

How to load a entity or node in form builder class?

I want to load default values in my form. I am fetching the node of the table row from form list and passing it into route. my_form_eform: path: '/edit/{bar}' options: parameters: bar: type: ...
0
votes
2answers
107 views

Add Field as Entity in Group Module

The group module is an alternative to the og module. The og module allows you to assign permissions to fields per group. I would like to be able to do the same thing with the group module. It ...
2
votes
1answer
545 views

Creating child nodes when creating parent

I'm trying to implement creation of child nodes programmatically in hook_submit when creating parent nodes according to the parent node field value. Here is the idea. Parent node: field_stages (...
1
vote
1answer
597 views

How can i display child terms under parent terms and assigned articles using entity field query?

Hi i have one content type with two vocabulary term references one is called category and terms is A,B,C like the 2nd one resources it contains parent with child terms like below hierarchy Resource ...
1
vote
1answer
36 views

Alter user's entity label method

By default the label() method of the user entity returns the username. So everywhere on the website where user references are used, the username is displayed. I need to alter this method so ...
2
votes
2answers
566 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
1answer
552 views

How to add a class to the <a> link elements within a Multiple Values field in a View?

I have a Views field (in this case, taxonomy term references) with Multiple Values set to "Display all values in the same row", using the Link formatter and a seperator. I want to add a class to each "...
0
votes
1answer
492 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 ...
0
votes
1answer
396 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 ...
1
vote
1answer
511 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 ...
22
votes
2answers
23k views

Programmatically update an entity reference field

I know I can update (or set a value for) an entity reference field in Drupal 7 with code similar to the following. $node['field_code_used_by'][LANGUAGE_NONE][0]['target_id'] = $id; I want to ...
2
votes
2answers
855 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 ...
0
votes
0answers
39 views

Change table_name in Content Entity

In Drupal 8 I have an entititype that I want to save to a different database i.e. not the default. I found this post on Drupal Answers, that seems to offer a solution. I'm not sure how to implement it....
2
votes
1answer
588 views

Is it fine to use hook_entity_view_mode_alter() to intercept an entity view to change the view mode based on an attached field value?

Basically I want to let the content creator choose an arbitrary view mode. For example, be able to choose a gallery that is a FlexSlider slideshow, a Masonry jQuery plugin type image gallery, or an ...
2
votes
2answers
1k views

How to override a module theme function in a custom module but still allow themes to override the template file?

I'm writing a fairly simple module which allows the removal of colons from field output on a per field basis and I need to override the core field module's theme_field function in my module. I can ...
3
votes
1answer
358 views

How to automatically modify a field after saving content?

I have posted this question on drupal.org (via a comment titled "field modification triggered by saving action"), but I realized that the thread is more than five years old. So I reproduce here the ...
1
vote
1answer
366 views

Entity reference field dependent on entity reference in referenced entity of another entity reference field

I have a content type 'order' with 2 entity reference fields. One is a reference to another content type 'brand' and the other is a reference to a taxonomy term 'categories'. Now the content type '...
0
votes
1answer
599 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::...
0
votes
2answers
633 views

How to validate deletion of custom entity?

I'm making decently complex system, where many entities are referencing each other, and I don't want to allow any broken references. That is why I would like to implement validation at entity deletion,...
2
votes
1answer
525 views

Is it possible to get Entity Connect and Entity Reference View Widget to work together and if so how?

It seems to me this should be a fairly common problem, but I can't seem to find and answer despite looking! Here is my use case: I have two types of content: Activity and Participants. When I create ...
0
votes
1answer
782 views

How to access weight of a paragraph in twig?

I use paragraphs with my content type. I need to show weight (order) value of each paragraph in my twig template. I can change weight with select box when I edit the node, but I can't figure out how ...
1
vote
1answer
563 views

How to set and inherit variables within different twig templates?

I'd like to set a variable in my node.html.twig template: {% set title = label %} {{ content }} The content consists of one field visible only, which has it's own template: file-link.html.twig How ...
-2
votes
1answer
23 views

How to restrict/provide access to particular entities of some ENTITY_TYPE to users which has email listed as field value?

I have a entity type Products with multiple entities in it. I want to give View, Edit, Delete Access of each entity to users only whose Emails are listed under field_user_email. I want to restrict ...
1
vote
1answer
649 views

Create relationship betweeen content type and custom entity on specific field

I'm trying to create a two-way relationship between my custom entity (package_date) and a content type (package) - the relationship is between a specific field on package and package_date (i.e. it's ...
1
vote
0answers
547 views

Field collection template file no output on render

I'm using Drupal 7 with field collection module. I have the template files set up and rendered with a call to render(). However, even though the templates are executed, the output is thrown away. ...
0
votes
1answer
71 views

Get node data from entity reference field

I have an entity reference field to a content type blog. I referenced a specific blog, but when I render that field in twig using {{ content.field_blog }}. I want to get the autor name and time when ...
1
vote
1answer
616 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 ...
1
vote
3answers
536 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 ...