Skip to content

Commit

Permalink
Fill in blanks for IntegerWeightSelector (Islandora#2065) (#863)
Browse files Browse the repository at this point in the history
Authored-by: Ant Brown <[email protected]>
  • Loading branch information
antbrown authored Mar 25, 2022
1 parent 4c439d4 commit bd98028
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Plugin/views/field/IntegerWeightSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bd98028

Please sign in to comment.