From bd98028f0026653ac285d3a45602f5c5f697131a Mon Sep 17 00:00:00 2001 From: Ant Brown Date: Sat, 26 Mar 2022 04:56:55 +1300 Subject: [PATCH] Fill in blanks for IntegerWeightSelector (Islandora#2065) (#863) Authored-by: Ant Brown --- 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 141d3567b..60892c960 100644 --- a/src/Plugin/views/field/IntegerWeightSelector.php +++ b/src/Plugin/views/field/IntegerWeightSelector.php @@ -46,12 +46,13 @@ public function viewsForm(array &$form, FormStateInterface $form_state) { $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;