New answers tagged

1 vote

Unable to add newly created term to the node

To append an entity reference item use: $node->field_foo[] = ['target_id' => 123]; And as Kevin noted in the comments, make sure you save the entity. $node->save();
user avatar
  • 163k
1 vote
Accepted

Access Denied for programmatically added file to a node

At the page /admin/reports/access-denied it can be found where the access denied is fired. Comparing with a working situation I find that it is necessary to add also a line in the file_usage table. ...
user avatar
  • 11
0 votes
Accepted

How to put a phone number in one place and call it from various other places?

If you want something like variable substitution, yes you can use Token module for that. You will need to create a custom module and define your own tokens. This is because the Token module only ...
user avatar
0 votes

Access Denied for programmatically added file to a node

Your code looks OK to me. However, not sure what file permission you want. Have you tried passing user id to see whether you are able to see the uploaded file? $file = File::create([ 'filename'...
user avatar
0 votes
Accepted

502 Bad Gateway on editing or creating only for one content type

This appears to be a well-understood, standard NGinx as proxy occurrence.
user avatar
  • 2,602
5 votes

Node ID caching on hook_form_alter()

When you get route parameters you need this cache context: $form['#cache']['contexts'][] = 'route'; You might also want to add the node cache data so that the form gets invalidated when the node is ...
user avatar
  • 86.9k
3 votes

Node ID caching on hook_form_alter()

The problem is that the webform gets cached with the $node data from the first node visited, but you need the webform to be unique per node. You can unset the cache keys for your webform - this will ...
user avatar
  • 6,823
0 votes

How can I disable revisioning on specific node field

As the content of your field is dynamically generated, it sounds like you need a computed field. Which will remove the issue you are running into. A computed field is one that is generated dynamically,...
user avatar
  • 14.5k

Top 50 recent answers are included