Get an array of the existing choices for a multiple-choice text field.
500095
def getFieldChoices(dbid,fieldName=nil,fid=nil)
      getSchema(dbid)
      if fieldName
         fid = lookupFieldIDByName(fieldName)
      elsif not fid
         raise "'fieldName' or 'fid' must be specified"
      end
      field = lookupField( fid )
      if field
         choices = []
         choicesProc = proc { |element|
            if element.is_a?(REXML::Element)
               if element.name == "choice" and element.has_text?
                  choices << element.text
               end
            end
         }
         processChildElements(field,true,choicesProc)
         choices = nil if choices.length == 0
         choices
      else   
         nil
      end
   end
1169757
protected function get_array_of_choices($question) {
        $subquestions = $question->options->answers;
        $count = 0;
        foreach ($subquestions as $key => $subquestion) {
            $answers[$count]['id'] = $subquestion->id;
            $answers[$count]['answer'] = $subquestion->answer;
            $answers[$count]['fraction'] = $subquestion->fraction;
            $answers[$count] += $this->feedback_to_choice_options($subquestion->feedback);
            $answers[$count]['choice'] = $count + 1;
            ++$count;
        }
        return $answers;
    }
1229495
def get_select_items(items):
    """"""
    option_items = list()
    for item in items:
        if isinstance(item, dict) and defs.VALUE in item and defs.LABEL in item:
            option_items.append(item[defs.VALUE])
        else:
            raise exceptions.ParametersFieldError(item, "a dictionary with {} and {}"
                                                  .format(defs.LABEL, defs.VALUE))
    return option_items
406453
def selections(self):
        ""
        for key, value in self.pairs:
            if '__' in key:
                column, lookup = key.rsplit('__', 1)
            else:
                column = key
                lookup = 'exact'
            yield column, lookup, value
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());
			
		}
991729
private List<?> getNewOptions(final String[] paramValues) {
		// Take a copy of the old options
		List<?> copyOldOptions = new ArrayList(getOptions());

		// Create a new list to hold the shuffled options
		List<Object> newOptions = new ArrayList<>(paramValues.length);

		// Process the option parameters
		for (String param : paramValues) {
			for (Object oldOption : copyOldOptions) {
				// Match the string value of the option
				String stringOldOption = String.valueOf(oldOption);
				if (Util.equals(stringOldOption, param)) {
					newOptions.add(oldOption);
					copyOldOptions.remove(oldOption);
					break;
				}
			}
		}

		return newOptions;
	}
1250137
def _choices(self):
        
        # Generate key/value strings
        pairs = []
        for key, value in self.choices.items():
            pairs.append(str(value) + "=" + str(key))

        # Assemble into overall string and escape
        return GPTaskSpec.manifest_escape(";".join(pairs))
822793
def get_choice(cls, value):
        
        attribute_for_value = cls.attributes[value]
        return cls._fields[attribute_for_value]
533333
def _build_field_choices(self, fields):
        
        return tuple(sorted(
            [(fquery, capfirst(fname)) for fquery, fname in fields.items()],
            key=lambda f: f[1].lower())
        ) + self.FIELD_CHOICES
996263
def render_multiplechoicefield(field, attrs, choices=None):
	
	choices = format_html_join("", wrappers.CHOICE_TEMPLATE, get_choices(field))
	return wrappers.MULTIPLE_DROPDOWN_WRAPPER % {
		"name": field.html_name,
		"field": field,
		"choices": choices,
		"placeholder": attrs.get("placeholder") or get_placeholder_text(),
		"style": pad(attrs.get("_style", "")),
		"icon": format_html(wrappers.ICON_TEMPLATE, attrs.get("_dropdown_icon") or "dropdown"),
	}
1012449
private function getSortFieldChoices()
    {
        $choices = [];
        foreach ($this->getSortFieldValues() as $sortField) {
            $choices[$this->getSortFieldLabel($sortField)] = $sortField;
        }

        return $choices;
    }
1275930
def choices(cls, blank=False):
        
        choices = sorted([(key, value) for key, value in cls.values.items()], key=lambda x: x[0])
        if blank:
            choices.insert(0, ('', Enum.Value('', None, '', cls)))
        return choices
891385
def _get_choices(self, gandi):
        
        return [str(item['id'])
                for item in gandi.snapshotprofile.list(target=self.target)]
1326223
public function getChoiceFields()
    {
        $choices = parent::getChoiceFields();

        // Shift all extended fields into the "lead" object.
        $resort = false;
        foreach (['extendedField', 'extendedFieldSecure'] as $key) {
            if (isset($choices[$key])) {
                foreach ($choices[$key] as $fieldAlias => $field) {
                    $choices['lead'][$fieldAlias] = $field;
                    unset($choices[$key][$fieldAlias]);
                }
                unset($choices[$key]);
                $resort = true;
            }
        }
        // Sort after we included extended fields (same as core).
        if ($resort) {
            foreach ($choices as $key => $choice) {
                $cmp = function ($a, $b) {
                    return strcmp($a['label'], $b['label']);
                };
                uasort($choice, $cmp);
                $choices[$key] = $choice;
            }
        }

        return $choices;
    }
195260
def get_choices(cls, condition=None, order_by=None, query=None, value_field=None, text_field=None):
        
        result = []
        if query is None:
            query = cls.filter(condition).order_by(order_by)
        for row in query:
            if not value_field:
                value = row._key
            else:
                value = getattr(row, value_field)
            if not text_field:
                text = unicode(row)
            else:
                text = getattr(row, text_field)
            result.append((value, text))
        return result
1278279
function ChoiceManager() {
        var that;
        that = this;

        /**
         * ### ChoiceManager.dl
         *
         * The clickable list containing all the forms
         */
        this.dl = null;

        /**
         * ### ChoiceManager.mainText
         *
         * The main text introducing the choices
         *
         * @see ChoiceManager.spanMainText
         */
        this.mainText = null;

        /**
         * ### ChoiceManager.spanMainText
         *
         * The span containing the main text
         */
        this.spanMainText = null;

        /**
         * ### ChoiceManager.forms
         *
         * The array available forms
         *
         * @see ChoiceManager.formsById
         */
        this.forms = null;

        /**
         * ### ChoiceManager.forms
         *
         * A map form id to form
         *
         * Note: if a form does not have an id, it will not be added here.
         *
         * @see ChoiceManager.forms
         */
        this.formsById = null;

        /**
         * ### ChoiceManager.order
         *
         * The order of the forms as displayed (if shuffled)
         */
        this.order = null;

        /**
         * ### ChoiceManager.shuffleForms
         *
         * TRUE, if forms have been shuffled
         */
        this.shuffleForms = null;

        /**
         * ### ChoiceManager.group
         *
         * The name of the group where the list belongs, if any
         */
        this.group = null;

        /**
         * ### ChoiceManager.groupOrder
         *
         * The order of the list within the group
         */
        this.groupOrder = null;

        /**
         * ### ChoiceManager.formsOptions
         *
         * An object containing options to be added to every form
         *
         * Options are added only if forms are specified as object literals,
         * and can be overriden by each individual form.
         */
        this.formsOptions =  {
            title: false,
            frame: false,
            storeRef: false
        };

        /**
         * ### ChoiceManager.freeText
         *
         * If truthy, a textarea for free-text comment will be added
         *
         * If 'string', the text will be added inside the the textarea
         */
        this.freeText = null;

        /**
         * ### ChoiceManager.textarea
         *
         * Textarea for free-text comment
         */
        this.textarea = null;
    }
742430
def get_each_choice(self, cls=None, **kwargs):
        
        defaults = {attr: kwargs[attr][0] for attr in kwargs}
        for set_of_values in izip_longest(*kwargs.values()):
            case = cls() if cls else self._CasesClass()
            for attr, value in izip(kwargs.keys(), set_of_values):
                if value is None:
                    value = defaults[attr]
                setattr(case, attr, value)
            yield case