Commit bfcd644b authored by webchick's avatar webchick

Issue #2326727 by swentel: Fixed Delete tempstore entry of preview in submit.

parent f941bebb
......@@ -97,9 +97,6 @@ public function form(array $form, FormStateInterface $form_state) {
$form_state['rebuild'] = TRUE;
$this->entity = $preview['controller']->getEntity();
unset($this->entity->in_preview);
// Remove the entry from the temp store.
$store->delete($uuid);
}
/** @var \Drupal\node\NodeInterface $node */
......@@ -500,6 +497,12 @@ public function save(array $form, FormStateInterface $form_state) {
else {
$form_state->setRedirect('<front>');
}
// Remove the preview entry from the temp store, if any.
$store = $this->tempStoreFactory->get('node_preview');
if ($store->get($node->uuid())) {
$store->delete($node->uuid());
}
}
else {
// In the unlikely case something went wrong on save, the node will be
......
......@@ -145,6 +145,12 @@ function testPagePreview() {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
// Assert the content is kept when reloading the page.
$this->drupalGet('node/add/page', array('query' => array('uuid' => $uuid)));
$this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
// Save the node.
$this->drupalPostForm('node/add/page', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit[$title_key]);
......
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