diff --git a/event/listener.php b/event/listener.php index e4f3e47..3c40b5b 100644 --- a/event/listener.php +++ b/event/listener.php @@ -162,7 +162,7 @@ protected function get_selected_prefix($event) $prefix_id = $this->request->variable('topic_prefix', 0); // If we are in preview mode, send back the prefix from the form - if (!empty($event['preview'])) + if (!empty($event['preview']) && $event['mode'] !== 'edit') { return $prefix_id; } diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 4486e63..2bbea07 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -214,6 +214,18 @@ public function data_add_to_posting_form() 'SELECTED_PREFIX' => '[foo]', ), ), + array( // test adding selected prefix when previewing a new topic + $prefix_data, + array( + 'mode' => 'post', + 'preview' => true, + ), + 1, + array( + 'PREFIXES' => $prefix_data, + 'SELECTED_PREFIX' => '[foo]', + ), + ), array( // test adding null selected prefix when posting new topic with bad data $prefix_data, array('mode' => 'post'), @@ -223,6 +235,18 @@ public function data_add_to_posting_form() 'SELECTED_PREFIX' => '', ), ), + array( // test adding null selected prefix when previewing new topic with bad data + $prefix_data, + array( + 'mode' => 'post', + 'preview' => true, + ), + 2, + array( + 'PREFIXES' => $prefix_data, + 'SELECTED_PREFIX' => '', + ), + ), array( // test post preview mode shows the expected prefix when no prefix is selected $prefix_data, array(