Fill Select2 input field and select a value

@When /^(?:|I )fill in select2 input "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" and select "(?P<entry>(?:[^"]|\\")*)"$/
15188
public function iFillInSelect2InputWithAndSelect($field, $value, $entry)
    {
        $page = $this->getSession()->getPage();

        $this->openField($page, $field);
        $this->fillSearchField($page, $field, $value);
        $this->selectValue($page, $field, $entry, $this->timeout);
    }
1293452
public function select2Row($model, $attribute, $htmlOptions = array())
	{
		return $this->inputRow(CiiInput::TYPE_SELECT2, $model, $attribute, null, $htmlOptions);
	}
2904
function (value, strategy, e) {
      var pre = this.getTextFromHeadToCaret();
      var post = this.el.value.substring(pre.length);
      var newSubstr = strategy.replace(value, e);
      var regExp;
      if (typeof newSubstr !== 'undefined') {
        if ($.isArray(newSubstr)) {
          post = newSubstr[1] + post;
          newSubstr = newSubstr[0];
        }
        regExp = $.isFunction(strategy.match) ? strategy.match(pre) : strategy.match;
        pre = pre.replace(regExp, newSubstr);
        this.$el.val(pre + post);
        this.el.focus();
        var range = this.el.createTextRange();
        range.collapse(true);
        range.moveEnd('character', pre.length);
        range.moveStart('character', pre.length);
        range.select();
      }
    }
831167
def fill_in_by_selector(self, selector, value):
    """"""
    elem = find_element_by_jquery(world.browser, selector)
    elem.clear()
    elem.send_keys(value)
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);
  }
546466
function massageSelector(input) {
  var result = pouchdbUtils.clone(input);
  var wasAnded = false;
  if ('$and' in result) {
    result = mergeAndedSelectors(result['$and']);
    wasAnded = true;
  }

  ['$or', '$nor'].forEach(function (orOrNor) {
    if (orOrNor in result) {
      // message each individual selector
      // e.g. {foo: 'bar'} becomes {foo: {$eq: 'bar'}}
      result[orOrNor].forEach(function (subSelector) {
        var fields = Object.keys(subSelector);
        for (var i = 0; i < fields.length; i++) {
          var field = fields[i];
          var matcher = subSelector[field];
          if (typeof matcher !== 'object' || matcher === null) {
            subSelector[field] = {$eq: matcher};
          }
        }
      });
    }
  });

  if ('$not' in result) {
    //This feels a little like forcing, but it will work for now,
    //I would like to come back to this and make the merging of selectors a little more generic
    result['$not'] = mergeAndedSelectors([result['$not']]);
  }

  var fields = Object.keys(result);

  for (var i = 0; i < fields.length; i++) {
    var field = fields[i];
    var matcher = result[field];

    if (typeof matcher !== 'object' || matcher === null) {
      matcher = {$eq: matcher};
    } else if ('$ne' in matcher && !wasAnded) {
      // I put these in an array, since there may be more than one
      // but in the "mergeAnded" operation, I already take care of that
      matcher.$ne = [matcher.$ne];
    }
    result[field] = matcher;
  }

  return result;
}
87668
function (element) {
            $(element).find(':input').each(function (index, inputObj) {
                putFieldValue(inputObj, getFieldValue(inputObj), true);
            });
        }
84060
function submitSearch() {
    var searchInput = getSearchInput();
    // FIXME: SUI validation for select2 field
      if (!searchInput.valid) {
      alert('Please select team members');
      return;
    }
    console.log('publishing', searchInput);
    $('.search.message').html('Search results:');
    $('.search.message').removeClass('hidden');
    context.pubsub.status('queued', function(res) {
      console.log(res);
      var message = '';
      if (res.err) {
        message = res.err;
      } else {
        message = 'found <a target="_searchresult" href="' + res.status.uri + '">' + res.status.uri + '</a> from ' + res.status.source;
      }

      $('.search.message').append('<div>' + message + '</div>');
    });

    context.pubsub.search.queue(searchInput);
    context.queryLib.setAnnotationTags($('#searchCategories').val().split(','));
    context.queryLib.submitQuery();
  }
296229
def p_field_optional2_2(self, p):
        
        p[0] = Field(name=p[1], arguments=p[2], selections=p[3])
1236998
function(_value,_node){
            // for multiple select
            if (!!_node.multiple){
                var _map;
                if (!_u._$isArray(_value)){
                    _map[_value] = _value;
                }else{
                    _map = _u._$array2object(_value);
                }
                _u._$forEach(
                    _node.options,function(_option){
                        _option.selected = _map[_option.value]!=null;
                    }
                );
            }else{
                _node.value = _getValue(_value);
            }
        }
987430
function (target, value, text) {
			var inst = this._getInst(target),
				onChange = this._get(inst, 'onChange');
			$("#sbSelector_" + inst.uid).text(text);
			$(target).find("option[value='" + value + "']").attr("selected", TRUE);
			if (onChange) {
				onChange.apply((inst.input ? inst.input[0] : null), [value, inst]);
			} else if (inst.input) {
				inst.input.trigger('change');
			}
		}
45882
function validate_value( $valid, $value, $field, $input ){

		// bail early if empty
		if( empty($value['url']) ) {

			return $valid;

		}


		//if( substr($value['url'], 0, 4) !== 'http' ) {
		if( !$this->nicifyUrl( $value['url'] ) ){
			$valid = __('Value must be a valid URL', 'acf');

		}

		// return
		return $valid;

	}
1359577
function(input, options) {
        input = $(input);

        if (input.prop('tagName').toLowerCase() !== 'input') {
            throw new Error('TypeAhead must be initialized on an input field');
        }

        var self = this;

        options = this.setOptions(options, input);
        this.element = this.createElement()
            .attr('role', 'listbox')
            .aria('multiselectable', false);

        // The input field to listen against
        this.input = input;

        // Use default callbacks
        $.each({ sorter: 'sort', matcher: 'match', builder: 'build' }, function(key, fn) {
            if (options[key] === false) {
                return;
            }

            var callback;

            if (options[key] === null || $.type(options[key]) !== 'function') {
                callback = self[fn];
            } else {
                callback = options[key];
            }

            options[key] = callback.bind(self);
        });

        // Prefetch source data from URL
        if (options.prefetch && $.type(options.source) === 'string') {
            var url = options.source;

            $.getJSON(url, options.query, function(items) {
                self.cache[url] = items;
            });
        }

        // Enable shadow inputs
        if (options.shadow) {
            this.wrapper = this.render(this.options.shadowTemplate);

            this.shadow = this.input.clone()
                .addClass('is-shadow')
                .removeAttr('id')
                .prop('readonly', true)
                .aria('readonly', true);

            this.input
                .addClass('not-shadow')
                .replaceWith(this.wrapper);

            this.wrapper
                .append(this.shadow)
                .append(this.input);
        }

        // Set ARIA after shadow so that attributes are not inherited
        input
            .attr({
                autocomplete: 'off',
                autocapitalize: 'off',
                autocorrect: 'off',
                spellcheck: 'false',
                role: 'combobox'
            })
            .aria({
                autocomplete: 'list',
                owns: this.element.attr('id'),
                expanded: false
            });

        // Initialize events
        this.addEvents([
            ['keyup', 'input', 'onLookup'],
            ['keydown', 'input', 'onCycle'],
            ['clickout', 'element', 'hide'],
            ['resize', 'window', $.debounce(this.onHide.bind(this))]
        ]);

        this.initialize();
    }
308435
function _fillInputText(element, value, next) {
        var onFilled = chainAndErrorCallback.call(this, null, next);
        var onClear = chainAndErrorCallback.call(this, function () {
            element.type(value || '', onFilled);
        }, onFilled);

        element.clear(onClear);
    }
308785
function TagsInput(element, options) {
    this.itemsArray = [];

    this.$element = $(element);
    this.$element.hide();

    this.isSelect = (element.tagName === 'SELECT');
    this.multiple = (this.isSelect && element.hasAttribute('multiple'));
    this.objectItems = options && options.itemValue;
    this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : '';
    this.inputSize = Math.max(1, this.placeholderText.length);

    this.$container = $('<div class="bootstrap-tagsinput"></div>');
    this.$input = $('<input type="text" placeholder="' + this.placeholderText + '"/>').appendTo(this.$container);

    this.$element.after(this.$container);

    var inputWidth = (this.inputSize < 3 ? 3 : this.inputSize) + "em";
    this.$input.get(0).style.cssText = "width: " + inputWidth + " !important;";
    this.build(options);
  }
25583
function(inValue) {
		if (this.hasFocus()) {
			var v = this.allowHtml ? inValue : enyo.Control.escapeHtml(inValue).replace(/\n/g, "<br/>");
			document.execCommand("insertHTML", false, v);
		}
	}
635507
public static function selecty($options, $selected = null, $attribs = array())
    {
        $htmls = array();
        $htmls[] = self::select(null, $attribs, false);
        if (Arr::iterable($options)) {
            foreach ($options as $value => $title) {
                $option_attribs = array('value'=>$value);
                if ((string) $selected === (string) $value) {
                    $option_attribs['selected'] = 'selected';
                }
                
                $htmls[] = self::option($title, $option_attribs);
            }
        }
        $htmls[] = '</select>';
        return join("\n", $htmls);
    }