Commit 58e1286a authored by Robin Monks's avatar Robin Monks

Issue #1833508 by danielfdsilva, Robin Monks, pianomansam: URL query...

Issue #1833508 by danielfdsilva, Robin Monks, pianomansam: URL query parameters when using "Save and Add another" button
parent 7cccfb75
......@@ -199,6 +199,11 @@ function addanother_node_form_submit($form, &$form_state) {
_addanother_quelch_message($node);
theme('addanother_button_message', array('nid' => $node->nid));
// If there is a destination parameter, keep it for next cycle.
if (isset($_GET['destination'])) {
$_GET['destination'] = url(_addanother_node_add_path($node), array('query' => array('destination' => $_GET['destination'])));
}
$form_state['redirect'] = _addanother_node_add_path($node);
}
}
......@@ -313,4 +318,4 @@ function _addanother_node_add_path($node) {
$path = $_GET['q'];
}
return $path;
}
\ No newline at end of file
}
......@@ -57,8 +57,29 @@ class AddanotherTestCase extends DrupalWebTestCase {
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost("node/add/$nodetype", $edit, t('Save and add another'));
// Check that the node has been created
// Check that we ended up back at node add page.
$this->assertUrl("node/add/$nodetype");
// Create a node with a destination and add another.
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost("node/add/$nodetype", $edit, t('Save and add another'), array('query' => array('destination' => 'user')));
// Check that we ended up back at node add page.
$this->assertEqual($this->getUrl(), url("node/add/$nodetype", array('query' => array('destination' => 'user'), 'absolute' => TRUE)), 'Destination was retained.');
// Create a node with a destination and follow through to destination.
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost("node/add/$nodetype", $edit, t('Save'), array('query' => array('destination' => 'user')));
// Check that we ended up back at node add page.
$this->assertUrl("user");
}
}
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