/** * Insert the data to pass to JS in to the DOM * @return void */ public static function insert() { if (!self::$has_inserted) { self::$has_inserted = true; Requirements::insertHeadTags(self::get_script_tag()); } }
/** * @return string */ public function Field($props = array()) { $autocompleteID = $this->getAutocompleteID(); $jsConfig = $this->config; $jsConfig['data'] = $this->getCompleteData(); JSConfig::add($autocompleteID, $jsConfig); Requirements::javascript(AUTOCOMPLETEFIELD_BASE . '/js/typeahead.bundle.min.js'); Requirements::javascript(AUTOCOMPLETEFIELD_BASE . '/js/autocompletefield.js'); $output = array(); foreach ($this->getChildren() as $field) { $field->setAttribute('data-autocomplete-id', $autocompleteID); $output[] = $field->Field(); } return implode('', $output); }