Browse Source

Fill in blanks for IntegerWeightSelector (Islandora#2065) (#863)

Authored-by: Ant Brown <ant@catalyst.net.nz>
pull/866/head
Ant Brown 3 years ago committed by GitHub
parent
commit
bd98028f00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/Plugin/views/field/IntegerWeightSelector.php

5
src/Plugin/views/field/IntegerWeightSelector.php

@ -46,12 +46,13 @@ class IntegerWeightSelector extends FieldPluginBase {
$options[$this->getValue($row)] = $this->getValue($row); $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 // out the option list from 1 through the result count
// to make sure we have enough. (Blanks should only appear // to make sure we have enough. (Blanks should only appear
// at the beginning of the results list.) // at the beginning of the results list.)
// Also, blank values will break the selector, remove it. // 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['']); unset($options['']);
for ($i = 1; $i <= $this->view->total_rows; $i++) { for ($i = 1; $i <= $this->view->total_rows; $i++) {
$options[$i] = $i; $options[$i] = $i;

Loading…
Cancel
Save