<commit_before><?php


App::uses('AppHelper', 'View/Helper');

class TagHelper extends AppHelper {

/**
 * Other helpers to load
 *
 * @var public $helpers
 */
	public $helpers = array('Html', 'Form', 'Js');
	public $options = array(
		'tag_placeholder' => 'search/add tags...',
		'tag_hidden' => false,
		'tag_width' => '90%',
		'tag_autocomplete' =>  false,
		'tag_data' => [],
		'tag_maxselect' => null
	);

	public function input($field, $identifier, $options=array()) {
		$options = am($this->options, $options);

		$this->Html->css("bootstrap-tagsinput.css", array('block' => 'css'));
		$this->Html->script("bootstrap-tagsinput.min", array('block' => 'script'));
		$this->Html->script("Tags.taginput", array('block' => 'script'));

		$formopts = [
			'type' => 'hidden',
			'class' => 'select2tags',
			'multiple' => true,
			'label' => false,
			'legend' => false,
			'div' => false,
			'tags' => json_encode($options['tag_data']),
			'placeholder' => $options['tag_placeholder'],
			'data-placeholder' => $options['tag_placeholder'],
			'identifier' => $identifier,
			'maxselect' => $options['tag_maxselect']
		];
		if ($options['tag_autocomplete']) {
			$formopts['url'] = $this->Html->url(array('action'=>'autocomplete_tags')) . ".json";
		}
		if ($options['tag_width']) $formopts['style'] = "width: {$options['tag_width']}";

		echo $this->Form->input($field, $formopts);

		$far = explode('.',$field);
		$tagid = "#";
		foreach ($far as $f) {
			$tagid .= ucfirst($f);
		}
		$this->Js->buffer("handleTags('$tagid');");
	}

}<commit_msg>fixed autocomplete issue. now can pass boolean or a complete url to tag_autocomplete option<commit_after><?php


App::uses('AppHelper', 'View/Helper');

class TagHelper extends AppHelper {

/**
 * Other helpers to load
 *
 * @var public $helpers
 */
	public $helpers = array('Html', 'Form', 'Js');
	public $options = array(
		'tag_placeholder' => 'search/add tags...',
		'tag_hidden' => false,
		'tag_width' => '90%',
		'tag_autocomplete' =>  false,
		'tag_data' => [],
		'tag_maxselect' => null
	);

	public function input($field, $identifier, $options=array()) {
		$options = am($this->options, $options);

		$this->Html->css("bootstrap-tagsinput.css", array('block' => 'css'));
		$this->Html->script("bootstrap-tagsinput.min", array('block' => 'script'));
		$this->Html->script("Tags.taginput", array('block' => 'script'));

		$formopts = [
			'type' => 'hidden',
			'class' => 'select2tags',
			'multiple' => true,
			'label' => false,
			'legend' => false,
			'div' => false,
			'tags' => json_encode($options['tag_data']),
			'placeholder' => $options['tag_placeholder'],
			'data-placeholder' => $options['tag_placeholder'],
			'identifier' => $identifier,
			'maxselect' => $options['tag_maxselect']
		];
		if (!empty($options['tag_autocomplete'])) {
			$formopts['url'] = $this->Html->url(array('action'=>'autocomplete_tags')) . ".json";
			if ($options['tag_autocomplete'] !== true) {
				$formopts['url'] = $options['tag_autocomplete'] . ".json";
			}
		}
		if ($options['tag_width']) $formopts['style'] = "width: {$options['tag_width']}";

		echo $this->Form->input($field, $formopts);

		$far = explode('.',$field);
		$tagid = "#";
		foreach ($far as $f) {
			$tagid .= ucfirst($f);
		}
		$this->Js->buffer("handleTags('$tagid');");
	}

}
{'fraction_non_alphanumeric': 0.23515151515151514, 'fraction_numerical': 0.0018181818181818182, 'mean_word_length': 4.613945578231292, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7555992', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1138, 'n_words': 213}