Problem/Motivation
I'm trying to send a status message using the core messenger service in Drupal 10. The message ends up being duplicated.
Its getting printed twice on the mercury editor page due to line 12 ({{ form['status_messages'] }}`) of /mercury_editor/templates/mercury-editor-entity-form.html.twig.
Separate issue but related to the the same form (first time I have seen this) the following is printed out in the twig on development
<!-- INVALID FILE NAME SUGGESTIONS: See https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_theme_suggestions_alter
mercury_editor_entity_form -->Steps to reproduce
Don't judge as the following is just the start of my development for an assigned tasked and nowhere near complete.
I added the following to a hook_form_alter().
$messenger = \Drupal::messenger();
$state = $form["moderation_state"]['widget'][0]['state']['#default_value'];
$messenger->addMessage(t('This content is currently @state.', ['@state' => $state]), MessengerInterface::TYPE_WARNING);
And the screenshot is what I see on my content node using Mercury Editor.

The top is the message printed from core and the bottom from mercury-editor-entity-form.html.twig.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | two_status_messages.png | 48.31 KB | fizcs3 |
| Screenshot 2025-01-07 at 1.29.11 PM.png | 36.57 KB | pbabin |
Issue fork mercury_editor-3498042
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pbabin commentedComment #3
pbabin commentedComment #4
fizcs3 commentedI'm seeing the same duplication of status messages; on mercury_editor 2.2.4.

In our case, we are using the contrib
content_lockmodule, and it's message appears:What I'm finding is that the
{{ form['status_messages'] }}(mentioned above, and below) is displaying the second smaller status message.It's the page template that displays the larger "system" status message at the top via
{{ page.highlighted }}:So, it depends which status message style is wanted here? I presume the second one is what we want, less space used.
If so, then the task instead would be to remove the status message that displays in the highlighted region...
Comment #5
anirudhsingh19 commentedworking on this.
Comment #7
anirudhsingh19 commentedAs mentioned by @fizcs3, The duplicate messages were caused by 2 templates.
I think the later was better to be removed as the first one was styled better, according to the default administration theme.
Comment #8
jldust commentedWith the recent error changes in the Form Error Validations issue this has been resolved and should be included in the next tagged release.