Lazy-load the available choices for the select box
352259
public function load_choices() {
        global $CFG;
        if (is_array($this->choices)) {
            return true;
        }
        $this->choices = array_merge(
                array('0' => get_string('choosedots')),
                get_string_manager()->get_list_of_countries($this->includeall));
        return true;
    }
1360806
def _get_choices(self):
        
        if self._overridden_choices:
            # Note: choices is a property on Field bound to _get_choices().
            return self._choices
        else:
            menus = getattr(settings, "PAGE_MENU_TEMPLATES", [])
            return (m[:2] for m in menus)
122794
function() {
			
			var i, length, choicesList, secondSelectValues, testValue;
			
			// allowed values in second select
			secondSelectValues = this.valuesMatching[this.selects[0].getValue()];
			
			// all choices in second select
			choicesList = this.selects[1].choicesList;
			
			for (i = 0, length = choicesList.length; i < length; i += 1) {
				
				testValue = choicesList[i].value;
				
				if (inputEx.indexOf(testValue, secondSelectValues) === -1) {
					this.selects[1].hideChoice({ position: i }, false); // no updatedEvt in case of clear (because multiple clear could happen...)
				} else {
					this.selects[1].showChoice({ position: i });
				}
				
			}
			
		}
844931
public function getFormattedChoices()
    {
        $ret    = [];
        $loaded = [];

        // Populate the raw formatted array with just values as values
        foreach (array_keys($this->choices) as $value) {
            $ret[$value] = $value;
        }

        // First start with arbitrarily set choices map
        if ($this->choicesMap) {
            $loaded = array_intersect_key($this->choicesMap, $ret);
        }

        // Execute the user given callback
        if ($this->choicesCallback) {

              $callbackLoaded = call_user_func(
                  $this->choicesCallback,
                  // Exclude already loaded items to leave the choices map
                  // having precedence over the callback
                  array_diff_key($ret, $loaded)
              );

              // We are forced to proceed to a two step merge (using foreach)
              // else array_merge() as well as the + operator would terribly
              // fail merging integer keys
              if ($callbackLoaded) {
                  foreach ($callbackLoaded as $value => $title) {
                      $loaded[$value] = $title;
                  }
              }
        }

        // Append the count for each value
        foreach ($this->choices as $value => $count) {
            $append = ' <span class="badge">' . $count . '</span>';
            if (isset($loaded[$value])) {
                $ret[$value] = $loaded[$value] . $append;
            } elseif(!$this->exclusiveMode) {
                $ret[$value] .= $append;
            }
            else {
                unset($ret[$value]);
            }
        }

        return $ret;
    }
1340021
private void initSelects(Benchmark... benchs) {
    String opt = "<input type='checkbox' name='n' value='%ID%' %SEL%>%ID%</input><br/>";
    selectPanel.add(new HTML("<div id=selectcontainer><strong>Make your selection</strong><hr/></div>"));
    selectPanel.show();
    GQuery g = $("#selectcontainer");
    for (Benchmark b : benchs) {
      String select = opt;
      for (String s : defaultBenchmarks) {
        if (s.equals(b.getId())) {
          select = select.replaceAll("%SEL%", "checked='checked'");
        }
      }
      g.append(select.replaceAll("%ID%", b.getId() + " " + b.getName()).replaceAll("%SEL", ""));
    }
    g.append("<br/><button id=run>Run</button>");
    $("#run").click(runBenchMarks);
    selectPanel.hide();
  }
1019971
function _keySelect() {
            var filteredChoices;

            if (lxSelect.choicesViewMode === 'panes') {
                filteredChoices = lxSelect.panes[(lxSelect.panes.length - 1)];
                if (!lxSelect.isLeaf(filteredChoices[lxSelect.activeChoiceIndex])) {
                    return;
                }
            } else {
                filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel);
            }

            if (filteredChoices.length && filteredChoices[lxSelect.activeChoiceIndex]) {
                lxSelect.toggleChoice(filteredChoices[lxSelect.activeChoiceIndex]);
            } else if (lxSelect.filterModel && lxSelect.allowNewValue) {
                if (angular.isArray(getSelectedModel())) {
                    var value = angular.isFunction(lxSelect.newValueTransform) ? lxSelect.newValueTransform(lxSelect.filterModel) : lxSelect.filterModel;
                    var identical = getSelectedModel().some(function (item) {
                        return angular.equals(item, value);
                    });

                    if (!identical) {
                        lxSelect.getSelectedModel().push(value);
                    }
                }

                lxSelect.filterModel = undefined;

                LxDropdownService.close('dropdown-' + lxSelect.uuid);
            }
        }
758908
function () {
			
			var i, j, ilength, jlength, currentSubChoices, currentSubChoice, currentValue,
			    testValue, isDuplicateChoice, secondSelectChoices;
			
			
			// object used in updateSecondSelectChoices
			//
			//   * key   : string representing a value in 1st select
			//   * value : array of values available in 2nd select when key is selected in first select
			//
			this.valuesMatching = {};
			
			
			// helper to filter 2nd select choices to find duplicates
			isDuplicateChoice = function(elt, arrElt) {
				elt    = lang.isObject(elt)    ? elt.value    : elt;
				arrElt = lang.isObject(arrElt) ? arrElt.value : arrElt;
				return elt === arrElt;
			};
			
			// collect 2nd level choices + ensure uniqueness of values
			secondSelectChoices = [];
			
			for (i = 0, ilength = this.options.choices.length; i < ilength; i += 1) {
				
				currentValue = lang.isObject(this.options.choices[i]) ? this.options.choices[i].value : this.options.choices[i];
				currentSubChoices = this.options.choices[i].choices;
				
				this.valuesMatching[currentValue] = [];
				
				// maybe no sub choices ???
				if (currentSubChoices) {
					for (j = 0, jlength = currentSubChoices.length; j < jlength; j += 1) {
					
						currentSubChoice = currentSubChoices[j];
					
						testValue = lang.isObject(currentSubChoice) ? currentSubChoice.value : currentSubChoice;
					
						this.valuesMatching[currentValue].push(testValue);
					
						if (inputEx.indexOf(testValue, secondSelectChoices, isDuplicateChoice) === -1) {
							secondSelectChoices.push(currentSubChoices[j]);
						}
					
					}
				}
				
			}
			
			
			// create and store selects
			this.selects = [];
			this.selects.push(new inputEx.SelectField({ choices: this.options.choices }));
			this.selects.push(new inputEx.SelectField({ choices: secondSelectChoices }));
			
			// append <select>s to DOM tree
			this.fieldContainer.appendChild(this.selects[0].getEl());
			this.fieldContainer.appendChild(this.selects[1].getEl());
			
		}
1110708
function getChoices() {
    return {
      roleIdentifiers: () => {
        return plugin.loadRoles()
        .then(roles => {
          // Build the list of available roles for input verification and interactive selection
          return _.map(roles, role => {
            return {
              value: role.name,
              name: role.name + (role.description ? ' - ' + role.description : '')
            };
          });
        });
      }
    };
  }
63357
def _get_selected_items(self):
        """"""
        selection = self.get_selection()
        if selection.get_mode() != gtk.SELECTION_MULTIPLE:
            raise AttributeError('selected_items only valid for '
                                 'select_multiple')
        model, selected_paths = selection.get_selected_rows()
        result = []
        for path in selected_paths:
            result.append(model[path][0])
        return result
721133
function SelectList(options) {
		this.options = $.extend({
			holder: null,
			maxVisibleItems: 10,
			selectOnClick: true,
			useHoverClass: false,
			useCustomScroll: false,
			handleResize: true,
			multipleSelectWithoutKey: false,
			alwaysPreventMouseWheel: false,
			indexAttribute: 'data-index',
			cloneClassPrefix: 'jcf-option-',
			containerStructure: '<span class="jcf-list"><span class="jcf-list-content"></span></span>',
			containerSelector: '.jcf-list-content',
			captionClass: 'jcf-optgroup-caption',
			disabledClass: 'jcf-disabled',
			optionClass: 'jcf-option',
			groupClass: 'jcf-optgroup',
			hoverClass: 'jcf-hover',
			selectedClass: 'jcf-selected',
			scrollClass: 'jcf-scroll-active'
		}, options);
		this.init();
	}
1349821
def choices(self):
        
        choice_list = getattr(
            settings, 'MARKUP_CHOICES', DEFAULT_MARKUP_CHOICES
        )
        return [(f, self._get_filter_title(f)) for f in choice_list]
1113706
function _getSelected(select) {
    const arr = [];

    _slice.call(select.options).map((el) => {
        if (el.selected) {
            arr.push(el.value);
        }
    });

    return arr;
}
93696
public function load_choices() {
        if (is_array($this->choices)) {
            return true;
        }
        $this->choices = array();

        if ($plugins = core_component::get_plugin_list('gradeexport')) {
            foreach($plugins as $plugin => $unused) {
                $this->choices[$plugin] = get_string('pluginname', 'gradeexport_'.$plugin);
            }
        }
        return true;
    }
1022493
public function load_choices() {
        if (is_array($this->choices)) {
            return true;
        }
        $this->choices = array(DEBUG_NONE      => get_string('debugnone', 'admin'),
            DEBUG_MINIMAL   => get_string('debugminimal', 'admin'),
            DEBUG_NORMAL    => get_string('debugnormal', 'admin'),
            DEBUG_ALL       => get_string('debugall', 'admin'),
            DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin'));
        return true;
    }
758865
function select (index) {
    // force form to update state for validation
    $mdUtil.nextTick(function () {
      getDisplayValue(ctrl.matches[ index ]).then(function (val) {
        var ngModel = elements.$.input.controller('ngModel');
        $mdLiveAnnouncer.announce(val + ' ' + ctrl.selectedMessage, 'assertive');
        ngModel.$setViewValue(val);
        ngModel.$render();
      }).finally(function () {
        $scope.selectedItem = ctrl.matches[ index ];
        setLoading(false);
      });
    }, false);
  }
379204
function fetchOptions(handler, data, board, callback) {
  if (_.isEmpty(data)) {
    return callback(null, data);
  }

  async.eachSeries(board.selects, (item, next) => {
    if (item.select) {
      return join(handler, data, item, board.type, next);
    }
    next();
  }, err => callback(err, data));
}
908237
public void loadChoices(String propertyName) {
        if (propertyName == null || propertyName.isEmpty()) {
            loadChoices(DEFAULT_CHOICES);
        } else {
            loadChoices(PropertyUtil.getValues(propertyName, null));
        }
    }