Drupal

Blog

How to check if a node entity is a newly save one

When working with entity forms I discovered this interesting piece detecting whether an entity is a newly saved one.

Blog

Directly get title of a referenced entity in Drupal 8 or 9

Entity references are common practice in drupal. With this snippet you can directly get the title of a referenced entity.

Blog

How to set default value of a drupal node form or entity form

Lately I had to prefill values on an entity form. Somewhat it did not work directly. Here is a working snippet.

Blog

How to set default value for entity reference programmatically in a form in drupal

Prefilling values is a common task. This snippet shows how to prefill a entity reference field

Blog

How to throw an exception to users in drupal

With custom development come a lot of entry points for users. This snippet throws access denied for users that are too curious on some paths.

Blog

A boilerplate Drupal Entity file

I realized there are not many resources to find a boilerplate custom entity. Here I share a code snippet containing one.

Subscribe to Drupal