This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

How do I get the error string?

I have the following code in a hook:

$errors = \Drupal::messenger()->messagesByType('error');
foreach ($errors as $error) {
  // $text = $error->getMessage();
}

The commented out line in the loop is to get the string of the error message. It does not use the right syntax.

What is the right syntax in procedural code?

Plugin block Derivatives

Am having trouble with creating blocks on the fly via my module.

I found information about Derivatives and Block Plugins. So far I can get the blocks to appear in the “Place block” modal,
but when I click on the “Place block” button in the modal I get an error.

Redirect to front page from hook_node_insert()

I want to redirect the user to the website's front page at the end of hook_node_insert()

However, drupal_goto() is gone. How do I do this in Drupal 9?

I've found this depreciation notice: https://www.drupal.org/node/2023537 which shows how to do it in a callback.

But just copying the procedural code example like this:

callBack in custom form

Hi, in a custom form I have 2 fields, one date and the other text
In the date field I inserted a callBack to display the day of the week but it doesn't work.Here is the code of the module present in the buildForm function

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions