Arkadiusz Dzięgiel avatar Arkadiusz Dzięgiel committed 1e41484

More options in widget

Comments (0)

Files changed (2)

Form/Type/TagsType.php

 	
 	public function getDefaultOptions(array $options)
 	{
-		return array();
+		return array(
+			'autocomplete_url' => null,
+			'autocomplete' => array(),
+			'height' => '100px',
+			'width' => '300px',
+			'interactive' => true,
+			'defaultText' => 'add a tag',
+			'removeWithBackspace' => true,
+			'minChars' => 0,
+			'maxChars' => 255, //if not provided there is no limit,
+			'placeholderColor' => '#666666'
+		);
 	}
 	
 	public function buildForm(FormBuilder $builder, array $options)
 	{
 		parent::buildForm($builder, $options);
-		 
-		//$builder->setAttribute('tinymce-config', $conf);
+		
+		$builder->setAttribute('tags-config', array_intersect_key($options, $this->getDefaultOptions(array())));
 		$builder->prependClientTransformer(new TagTransformer());
 	}
 	
-/*	public function buildView(FormView $view, FormInterface $form)
+	public function buildView(FormView $view, FormInterface $form)
 	{
-		//$view->set('config', $form->getAttribute('tinymce-config'));
-	}*/
+		$view->set('config', $form->getAttribute('tags-config'));
+	}
 }

Resources/views/Form/fields.html.twig

     <input {{ block('widget_attributes') }} value="{{ value }}" />
 	<script type="text/javascript">
 		$(function() {
-			$('#{{ id }}').tagsInput();
+			$('#{{ id }}').tagsInput({
+				{% for key, value in config %}{% spaceless %}
+					{{ key|json_encode|raw }}: {{ value|json_encode|raw }}{% if not loop.last %},{% endif %}
+				{% endspaceless %}{% endfor %}
+			});
 		});
 	</script>
 {% endspaceless %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.