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
1answer
456 views

How to check if a menu exists programatically in Drupal 8

I have a script where I instantiate and fill menus with menu items programmatically. Whats the best way to check if a menu already exists if I already know it's ID.
4
votes
2answers
3k views

How to get a list/array of all content entities?

I need a list of all content entities, to query them all and check if they have a specific field. Couldn't find this in the API doku.
1
vote
2answers
3k views

Entity Reference - show link on referenced node

I have a "Entity Reference" field in a custom content type. I want to show on any referenced node the link to the node. How can I do it?
0
votes
1answer
141 views

(Newbie question) Something goes wrong here with db_add_field

I'm trying to adapt that D6 module to D7. I'm on the "add afield" part of .install Here's my code : function node_statistics_install() { db_add_field('accesslog', 'nid', array( 'description' ...
1
vote
2answers
203 views

Create many to many Relationship with a specific fields in a Content type to taxonomy

I am currently encounter a problem, I have one content type (Type) and two taxonomy needed to be link up, in that content type, I need to apply a many to many relationship among a field (Name: Core) ...
2
votes
2answers
2k views

Set date field in D8

I'm developing a module where I have to set a user profile date_field. I tried several methods to implement this but not one worked for me. Here is my method (status today) private function ...
2
votes
0answers
26 views

Can't pass the checkout process [duplicate]

I'm having this error on my website EntityMalformedException: Missing bundle property on entity of type commerce_line_item. in entity_extract_ids() (line 7866 of /var/www/xxx/xxx/includes/common.inc). ...
2
votes
2answers
642 views

Set default image when file not found (404)

I have many images but when one of them is missing it displays an empty <img>. Is there a method or hook that can be used to display a default image instead this empty <img> tag?
2
votes
1answer
717 views

How can I add a custom attribute to a link field?

For analytics/tracking purposes, I would like to add a custom attribute to a link field. Is there a way to add an additional text field to the link, similar to the title attribute field?
0
votes
1answer
35 views

How to make an custom content entity can be refered like user in Drupal 8?

Follow project examples, I have created a content entity, but how can make it can be attached into another entity as a reference field like user in drupal 8?
1
vote
1answer
141 views

Put eform's label and textfield(input) separate

I'm working on creating a table with eForm in Drupal 8. Since label and textfield(input) stick together, can I insert label and textfield(input) into separate <td>?
0
votes
1answer
350 views

How to get the fields of the entity?

I need to get all the names of the entity, my entity is called 'a_process'? How can I write such query in Drupal 8? $nodes = entity_load_multiple('a_process', $name);
0
votes
1answer
400 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 ...
2
votes
1answer
429 views

Accessing content for a specific node revision via a relationship in Views

A module I've written implements hooks defined by the Field API to provide a custom field for defining references to specific node revisions by storing vids. (The module borrows functionality from the ...
0
votes
0answers
14 views

Many to many Relationship between content type [closed]

I am new in drupal and want to create a many to many relationship between 2 content types. Orders and products. I have found few answers related to my query but i couldn't achieve it. Will really ...
0
votes
1answer
453 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 }} {{ ...
1
vote
1answer
436 views

How to use Views PHP get Taxonomy field value and field collection value?

I am currently using Views PHP module to use Field Global PHP to render view value, but I dont know how to read taxonomy field value and field collection value, did anyone know how to do it?? Beside,...
0
votes
1answer
132 views

Show specific url path in admin theme

I want to edit in admin theme some editing pages like "entityform/*/edit". How can I do that?
1
vote
1answer
142 views

Does entity_save() trigger the update event?

Not quite sure if calling entity_save() from code will trigger the update event or not. So, does it?
0
votes
2answers
177 views

CCK field. how to use dynamic names to call CCK fields? (like: $node->$cckname)

I have several cck image fields. Each field has a consecutive name, for example: field_photos_1, field_photos_2, field_photos_3, field_photos_4 ... until 20 So my question is: How to call the image ...
0
votes
0answers
406 views

Entity form calculator in Drupal

I was wondering, is there anything like webform calculator for entity forms?
1
vote
1answer
477 views

How can I create a custom form settings to my custom field formatter?

I need to add form settings to my custom display format, can you provide me with an example? To be clear I just want to add some fields to the format settings form.
0
votes
1answer
394 views

hook_field_formatter_view does not get called

I have a custom field, that hooks into profile2 and saves it's value in user data blob. Everything works fine, except the hook_field_formatter_view, that does not get called for a reason. As a result, ...
-1
votes
1answer
44 views

Sent email to entity reference node email field on checkout

I have a commerce store and my client don't want a regler checkout. On the checkout a email must be sent to a marketer of the users choice. For this I have setup a content type with all the users ...
0
votes
1answer
401 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) { ...
1
vote
2answers
439 views

How to use Rules to send an eMail containing a list of nodes with a selected value in a field?

I try to send a list of nodes with certain value in a specific field via the Rules module. This is what I have so far: Event: "After updating existing content of type MyContentType" Conditions: "...
0
votes
1answer
395 views

Entityform (block) redirect not working

The redirect field within entityform doesn't seem to have any effect. I'm using the entityform block module, if it makes any difference. I have also tried using hook_form_alter to copy to default ...
0
votes
1answer
1k views

Saving date field programmatically on node, but not on profile

I'm saving some date field on the code both on node and profile entity. I'm success on saving it for nodes, but when I try to save for profile2 entity, using the same chunck of code, no data is saved. ...
6
votes
2answers
2k views

Character limit of field machine name?

Is the machine name of a Drupal 7 field limited to 32 characters (including field_)? When I'm creating a new field, the UI seems to cut me off there, but I wonder if this can be circumvented. I'm ...
0
votes
1answer
398 views

Drupal 7/Profile2: how to add fields and hide them from client?

I added fields to a Client profile using Profile2, such as first name and last name. But I added another fields, let's call it "Assigned Consultant". But the "Assigned Consultant" field... I don't ...
0
votes
1answer
435 views

Calculate values from multiple content items

I have a Drupal 7 website that will be used to track automobiles in a fleet, as well as their engines and a few other items. Regarding the engines, I will be tracking the number of hours the engine is ...
1
vote
1answer
398 views

Setting up a date field to require an end date

I'm attempting to create a custom content type for a module via hook_install. When I create a date type (from Date module), I want it to require an end date (there's a checkbox when you're setting up ...
2
votes
1answer
393 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 ...
1
vote
1answer
532 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 ...
-2
votes
1answer
26 views

Is hook_field_group_build_pre_render_alter() deprecated?

I just came accross hook_field_group_build_pre_render_alter when I was trying to add visibility #state to a field group on the User Regsiter Form (Hide a CCK fieldgroup using #states in ...
1
vote
2answers
436 views

D7 - 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
429 views

Using Entity metadata wrappers to change field value under hook_node_insert()

I am trying to change a field value inside both hook_node_insert() and hook_node_update() using EMW. It actually changes the original $node object that is passed to these hook functions but the change ...
0
votes
1answer
55 views

Entity getOwner()

In what table does an entity "foo" get its metadata stored? In Drupal 7, there are tables for all the fields for a content type and the node table had some metadata stored, but most data for a content ...
1
vote
2answers
496 views

Set value for new field automatically based on another field

I want to add a new date field to an existing content type, and set the new field automatically for existing nodes to be equal to another date field from that content type. For example, if the new ...
2
votes
2answers
771 views

How do I get $entity in hook_form_alter()?

hook_add_form() gets $entity_type and $entity as parameters, but hook_form_alter() does not have any of those parameters. How do I get the entity type and the entity object in hook_form_alter()in ...
1
vote
1answer
88 views

Disable field date and checkbox

I'm trying to disable input fields of type date and checkbox in hook_form_alter with above code: $key = 'field_name'; $form[$key]['widget'][0]['value']['#attributes']['disabled'] = true; $form[$key][...
2
votes
1answer
417 views

Entity reference Hierarchical Select between three content types?

I have three content types: Courses Sections Chapters Sections content type have Entity reference of Courses. Chapters content type have two entity reference fields as Courses and Sections. If I ...
0
votes
3answers
5k views

How to set default value for entity reference field in hook_form_alter [closed]

following snippet doesn't set the default value. $form['field_image']['#default_value']='default'; I Have content type called image and I'm trying to set the default value for a reference to it ...
1
vote
1answer
453 views

Custom view for Entityform submission

I have a simple Entityform where the user selects from a list of Profile2 user profiles (internal staff and external staff). In simpler terms, the user selects from a list of entities (ie. pick 3 from ...
0
votes
2answers
430 views

Define available default colors for Color Field programatically

I use the Color Field as a field in a custom module from where I create the content type programatically. By default the available colors are defined at this hook: color_field_field_settings_form in ...
4
votes
1answer
531 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
1answer
75 views

Use an Address Field with 3 lines for the street [closed]

I'm working on an Entity where I created a field containing Address informations (like country, city and street). The default Address Type in Drupal 8 supports only 2 lines for the street information....
5
votes
3answers
3k views

How to easily alter an entity's base field definition per bundle

We are using the group module in Drupal 8, which introduces a custom entity "group". This entity features a "label" base field with the title "Title". As groups administrator, you can create several ...
0
votes
1answer
419 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. ...
0
votes
0answers
31 views

How do I migrate content to a field added with UI to an existing custom content entity?

In a custom module (assoc), I have a custom Content Entity (Person) with these fields: $fields['lastname'] = BaseFieldDefinition::create('string') $fields['firstname'] = BaseFieldDefinition::create('...