Skip to main content
The 2024 Developer Survey results are live! See the results

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
21 votes
5 answers
6k views

Is displaying a working Field Widget Form on its own possible?

I'm interested in embedding a Field Widget Form out side the context of the whole node edit form. I have displayed full forms in the past using drupal_get_form but that doesn't seem to apply for ...
SMTF's user avatar
  • 946
27 votes
5 answers
22k views

Using OR with EntityFieldQuery

I have never had the need to do this before today, but it doesn't seem like you can make OR queries with EntityFieldQuery, since db_or is used for select queries. An example would get to all entities ...
googletorp's user avatar
  • 35.4k
2 votes
1 answer
1k views

Rule to store user's last post date and scheduled rule based 30 day reminder

In this scenario, user's can post 1 node of a specific content type every 30 days (interval changes depending on user role). We are using node_limit to accomplish this; it's doesn't play with rules. ...
Sam Roy's user avatar
  • 53
46 votes
15 answers
47k 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 ...
artfulrobot's user avatar
  • 4,029
14 votes
4 answers
20k views

Add content type field programmatically

My module provides a configuration form which allows to select a content type and on submit 2 new fields will be added to the selected content types. I want to add these fields to the content types ...
Kpone's user avatar
  • 503
49 votes
3 answers
30k views

How to provide template for particular view mode?

I want to theme the search result view mode with a template. I had it in my head that naming a template file node--article--search-result.tpl.php would do the trick, but I'm obviously wrong about ...
artfulrobot's user avatar
  • 4,029
80 votes
11 answers
235k views

How do I access a field value for an entity (e.g. node) object?

node_load((int) $nid) loads a fully-populated node entity. $node->title->value gets the title, but how do I access field values in Drupal 8?
dbj44's user avatar
  • 4,764
78 votes
4 answers
74k views

How do I load a field collection from a node?

I have a node that has a few field collections on it. When I look at node_load() output, I see: [field_rich_text_group] => Array ( [und] => Array ( ...
Justin's user avatar
  • 3,703
9 votes
2 answers
10k views

Override theme template from module without implementing a theme

I have a project on D8 where I don't use any custom themes, I use default seven theme for everything because there is no need of any visual theming. So My question: Is it possible to override theme ...
otarza's user avatar
  • 954
88 votes
7 answers
18k views

When is it appropriate to create an entity instead of a new content type?

What is the benefit to creating new entity types over just building a new content type? It seems a bit overkill to do all of the custom coding that is required to create a new entity when you have ...
revolt's user avatar
  • 1,131
57 votes
9 answers
53k views

How to programmatically create Fields?

How can I approach implementing the following in Drupal 7? What I need to do is create a module which defines a new fieldable entity, called 'Company'. I have a list of, let's say, 20 fields that ...
NRaf's user avatar
  • 853
23 votes
3 answers
29k views

Get all fields defined in a bundle

In Drupal 7, to get all fields used in a content type, I use the following code. $fields = field_info_instances('node', 'article'); What is the equivalent for Drupal 8?
Pravin Ajaaz's user avatar
  • 3,552
20 votes
4 answers
11k views

Relation vs. References vs. Entity Reference for managing node-reference-type relationships

References Entity Reference Relation It seems like there are several active modules that all have similar functionality. Can anyone offer any information as to which branch appears to be the most ...
starsinmypockets's user avatar
19 votes
3 answers
16k views

How to debug EntityMalformedException?

I've got fatal error EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7700 of .\includes\common.inc) when trying to access user/xyz. I tried to ...
Kojo's user avatar
  • 3,513
10 votes
3 answers
8k 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 ...
Tijmen's user avatar
  • 101
8 votes
3 answers
7k views

Show node IDs along with titles in Entity reference Autocomplete list

I'll like to add this functionality to the autocomplete widget in Entityreference field to show node ID next to the titles in the dropdown list. The reason behind the idea is to differentiate between ...
neemu's user avatar
  • 81
5 votes
1 answer
7k views

Extracting URI value from Image in Views - Getting Index Error

I am trying to create a custom slideshow using Views. Please not that I am not using the Views Slideshow Module What I need to accomplish is to wrap the the relative URL for the images within a ...
Allan's user avatar
  • 563
3 votes
5 answers
4k views

How to bulk update select list fields?

I have a content type and it has a select list field. There are two options Yes or No and this field is not a required field. The website has about 100,000 nodes and I want to bulk update all nodes ...
herci's user avatar
  • 2,160
38 votes
7 answers
9k views

Is there a good way to inspect objects whose type is derived from the EntityDrupalWrapper class?

I'm sure this question applies to other complex object types, but EntityDrupalWrapper is the one I'm currently working with. This is the type of object returned by entity_metadata_wrapper() (and ...
Clive's user avatar
  • 167k
33 votes
4 answers
59k 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 ...
user avatar
30 votes
5 answers
28k views

Best practice for language key for "und" in hook_form_alter

I'm modifying in a form in my custom module. Code looks like: function my_module_form_alter(&$form, &$form_state, $form_id) { if ($form_id == "someID") { $form['...
Shafiul's user avatar
  • 1,226
24 votes
5 answers
19k views

How to set value of file field with entity_metadata_wrapper

How do you set the value of a file field when using the entity_metadata_wrapper? I've tried doing this in code: $file = new stdClass(); $file->uid = 1; $file->uri = $file_path; $file->...
Smos's user avatar
  • 647
11 votes
5 answers
40k views

How to print fields in node.tpl.php?

I need to print individual fields from the $content variable in node.tpl.php file in separate div tags. How do I do that and how do I find out what the field's names are?
CobaltBabyBear's user avatar
10 votes
4 answers
20k views

Autofilling fields based on another field

I have a very complex situation where I need some advice. I have a content type my_content, which has a field collection field attached to it field_mycollection, which has an entity reference field ...
Elin Y.'s user avatar
  • 7,349
9 votes
4 answers
37k views

Get the value of a field from an entity reference

I have a content type (Actuality) with an entity reference field to another content type (Event). In the referenced content type, I have a field_date field I want to print in the node--actuality.html....
lchabrand's user avatar
  • 364
2 votes
3 answers
1k views

How to add up all items of a field collection field using Rules?

I have a field collection with unlimited values. Inside this field collection, there is a field called Price (field_price). I would like to addup all prices that are inside the field collection to ...
No Sssweat's user avatar
  • 31.4k
2 votes
2 answers
2k views

How to fix entity property X doesn't support writing, when setting content type field values?

I've got a D7 content type with a few fields; nothing particularly special. I want to be able to programattically change the values of those fields from time to time, and so wrote a function like so: ...
Jim Miller's user avatar
  • 1,948
50 votes
7 answers
45k views

How to change the length of field settings?

I have set once to a website a lenght limit to a field. And now the client wants to put more characters to that field. I cannot change the maximum size from Drupal because I get the following error ...
EKK's user avatar
  • 4,350
36 votes
9 answers
6k views

What's a good balance between reusing fields versus creating new ones in the context of fields scalability?

I've read the following phrase on a website: Instead of adding new fields to a content type, adding existing fields is a better option to reduce the system’s complexity and to improve scalability. ...
rafamd's user avatar
  • 513
35 votes
5 answers
18k views

Bulk field update?

I added a new (text) field to a Drupal 7 content type that already has many nodes. How can I fill the field with a default value for all these nodes?
daphshez's user avatar
  • 1,082
20 votes
7 answers
15k views

fast saving single field value

I've got around 70k nodes of specified type on my site. I need to run an update on them. Some operations and setting one field to desired value. node_save is really slow and it causes crashes (too ...
Eloar's user avatar
  • 303
18 votes
4 answers
10k views

EntityFieldQuery vs Db_select()

Why should I use EntityFieldQuery when I can do the same work with Db_select() to fetch the value. It would be better if someone can provide an example, not only a link.
j2r's user avatar
  • 981
14 votes
5 answers
11k views

How do I alter the entity type class?

In Drupal 8 you can load an entity with: $node = \Drupal::entityManager()->getStorage('node')->load(123); This looks for the entity definitions and finds that node is defined by Drupal\node\...
itarato's user avatar
  • 425
13 votes
2 answers
6k views

Override field template with custom module

Instead of adding tpl files (in this case, media-youtube-video.tpl.php) to the theme. How can I override field templates from a custom module? Including when the field is used in a View.
Allan Thomas's user avatar
9 votes
1 answer
18k views

Send a form to twig template

How I can pass a form to twig template in Drupal 8? For example, I get this: a form: mymodule/src/Form/MyForm.php Then on my Controller: public function myController() { ?????? return [ ...
rpayanm's user avatar
  • 3,621
8 votes
3 answers
9k views

Listing entity fields

I wonder if there is a good, and easy way to get all fields of an entity. I have a taxonomy vocabulary. Its terms have a special field I want to make list in a select box in one of my modules, so ...
Johnny's user avatar
  • 235
7 votes
2 answers
4k views

How to implement a multi step approval with webforms/entityforms based on form components?

Is it possible to invoke multi-step submission workflow using either Webform or Entityform? Here is the scenario of workflows: An employee submits the form Superviser gets notification,...
JT-Drupal's user avatar
  • 115
6 votes
1 answer
3k views

Can I delete leftover field_deleted_* tables?

I have a lot of field_deleted_* tables in the database and neither drush cr or running cron is removing them. Is it okay to just remove them from the database? How can I tell Drupal to remove them ...
Kevin's user avatar
  • 27.9k
27 votes
1 answer
22k views

How to create a view type of Entity reference display?

I have an entity which contains a field collection of entity references and can edit the entity references with the Entity selection mode is Simple (with optional filter by bundle), but only Entity ...
vfclists's user avatar
  • 1,269
11 votes
1 answer
5k views

Entity reference vs. taxonomy

Let's say I have a team, which has members. I have a content type for team and a content type for individual team members. Let's say there are also other relationships, for instance teams can belong ...
James's user avatar
  • 1,191
6 votes
7 answers
11k views

How to place Contact form in block?

I have to embed a contact form inside of a block, and I'm trying to use the entity.form_builder service, But I'm not sure which entity I should give it, I found Message and ContactForm entity, so what ...
DenLilleMand's user avatar
4 votes
4 answers
8k views

Views with Entity Reference

I'm not sure why this is difficult for me to get. It seems like it should be simple. I have a content type A and content type B. Content type B has an entity reference field to content type A. ...
vintorg's user avatar
  • 1,993
3 votes
1 answer
1k views

How to iterate over all field collection items in an eMail body using Rules?

I'm trying to write a rule (using Rules) that will send an email to users of a role. Within the body of the email, I'd like to display the contents of a nested field collection. I've tried using what ...
rrirower's user avatar
  • 349
1 vote
1 answer
6k views

Field level permissions in Drupal 7

What is the best way to create a piece of content with multiple fields... allowing users to edit the content as a whole yet blocking the ability to edit. The setup I have is a piece of content that ...
WernerCD's user avatar
  • 784
1 vote
1 answer
247 views

How to set the values of some fields depending on the value of a list box?

Remember the create password page of Drupal! while you are entering characters it tells you how string is your password! now I want to have something like this in a list box but a bit different. I ...
shekoufeh's user avatar
  • 589
0 votes
2 answers
93 views

Entity Reference widget selctor in view referring same reference

I searched for a solution but I didn't get it right. Given my setup: A content type Service, referring a content type Agency A content type Agency A content type Person, referring a content type ...
Elgandoz's user avatar
32 votes
4 answers
36k views

How do I render nodes, now that node_view() has been deprecated?

In Drupal 7 I frequently use node_view() for rendering nodes (using view modes) in blocks or pages as follows: $nids = array(123,456,789); $nodes = node_load_multiple($nids); foreach ($nodes as $node)...
batigolix's user avatar
  • 2,614
25 votes
6 answers
27k views

Programmatically attaching files

I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field: $file = file_save_upload('...
Vinodkumar SC's user avatar
23 votes
4 answers
49k views

Perform a query with an entity field condition with multiple values

I have a content type that has a entity reference field that allows users to add multiple taxonomy terms in that field. I'm attempting to perform queries that grab nodes that have a specific set of ...
Amy's user avatar
  • 5,738
22 votes
5 answers
41k views

Hide a field label

Is there a way to hide the field label when rendering a custom field in Drupal 7? In my node template I have: <?php print render($content['field_image']); ?> Which gives me: <div class="...
Ben's user avatar
  • 323

1
2 3 4 5
19