Unverified Commit d9bd719b authored by larowlan's avatar larowlan
Browse files

Issue #2914839 by Sam152: The current moderation state in the "meta" region on...

Issue #2914839 by Sam152: The current moderation state in the "meta" region on content entity forms is coupled to the moderation_state field widget
parent 6029e8a9
......@@ -351,10 +351,10 @@ public function formAlter(array &$form, FormStateInterface $form_state, $form_id
$form['moderation_state']['#group'] = 'footer';
}
// Duplicate the label of the current moderation state to the meta
// region, if available.
// If the publishing status exists in the meta region, replace it with
// the current state instead.
if (isset($form['meta']['published'])) {
$form['meta']['published']['#markup'] = $form['moderation_state']['widget'][0]['current']['#markup'];
$form['meta']['published']['#markup'] = $this->moderationInfo->getWorkflowForEntity($entity)->getTypePlugin()->getState($entity->moderation_state->value)->label();
}
}
}
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\content_moderation\Functional;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\workflows\Entity\Workflow;
/**
......@@ -468,6 +469,23 @@ public function testContentTranslationNodeForm() {
], t('Save (this translation)'));
}
/**
* Test the moderation_state field when an alternative widget is set.
*/
public function testAlternativeModerationStateWidget() {
$entity_form_display = EntityFormDisplay::load('node.moderated_content.default');
$entity_form_display->setComponent('moderation_state', [
'type' => 'string_textfield',
'region' => 'content',
]);
$entity_form_display->save();
$this->drupalPostForm('node/add/moderated_content', [
'title[0][value]' => 'Test content',
'moderation_state[0][value]' => 'published',
], 'Save');
$this->assertSession()->pageTextContains('Moderated content Test content has been created.');
}
/**
* Tests that workflows and states can not be deleted if they are in use.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment