From 1b1bab98fd6e7b21bfc2d2ee0966686d9c99dd61 Mon Sep 17 00:00:00 2001 From: Ant Brown Date: Fri, 18 Mar 2022 21:44:17 +1300 Subject: [PATCH] Fill in blanks for IntegerWeightSelector (Islandora#2065) --- src/Plugin/views/field/IntegerWeightSelector.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Plugin/views/field/IntegerWeightSelector.php b/src/Plugin/views/field/IntegerWeightSelector.php index 141d3567..0c0f6e8c 100644 --- a/src/Plugin/views/field/IntegerWeightSelector.php +++ b/src/Plugin/views/field/IntegerWeightSelector.php @@ -46,12 +46,13 @@ class IntegerWeightSelector extends FieldPluginBase { $options[$this->getValue($row)] = $this->getValue($row); } - // If we were given some blank values we need to fill + // If we were given some blank values, or less than the + // total_rows for the view, we need to fill // out the option list from 1 through the result count // to make sure we have enough. (Blanks should only appear // at the beginning of the results list.) // Also, blank values will break the selector, remove it. - if (array_key_exists('', $options)) { + if (array_key_exists('', $options) || (count($options) < $this->view->total_rows)) { unset($options['']); for ($i = 1; $i <= $this->view->total_rows; $i++) { $options[$i] = $i;