Skip to content

Commit

Permalink
Prevent the selected targets being removed when a search is cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
steveblamey committed Jul 14, 2017
1 parent e5ebd32 commit 393a03f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/classes/standard/SelectorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,14 @@ public function select_targets()
$sh = new SearchHandler($items, false);
$sh->addConstraint(new Constraint($item->description . '_id', '=', $item->id));
$items->load($sh);
$_SESSION['selected_targets']['data'] = array();

// We may be here becuase the user cleared an item search.
// Only create the session array if there are no targets,
// otherwise the user's new selections will keep disapearing
if (empty($_SESSION['selected_targets']['data']) || empty($this->_data['search_id'])) {
$_SESSION['selected_targets']['data'] = [];
}

$idField = $items->getModel()->idField;
$items_data = $items->getArray();
if (! empty($items_data)) {
Expand Down Expand Up @@ -1206,7 +1213,7 @@ public function getSelectTreeBreadcrumbs()
echo $html;
exit();
}

/*
* Protected Functions
*/
Expand Down

0 comments on commit 393a03f

Please sign in to comment.