Source

TaggableBehaviorBundle / Form / Type / TagsType.php

<?php
namespace Propel\TaggableBehaviorBundle\Form\Type;

use Propel\TaggableBehaviorBundle\Form\DataTransformer\TagTransformer;

use Symfony\Component\Form\FormInterface;

use Symfony\Component\Form\FormView;

use Symfony\Component\Form\FormBuilder;

use Symfony\Component\Form\AbstractType;

class TagsType extends AbstractType {
	public function getParent(array $options)
	{
		return 'text';
	}
	
	public function getName()
	{
		return 'tags';
	}
	
	public function getDefaultOptions(array $options)
	{
		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',
			'class' => null,
		);
	}
	
	public function buildForm(FormBuilder $builder, array $options)
	{
		parent::buildForm($builder, $options);
		
		$builder->setAttribute('tags-config', array_intersect_key($options, $this->getDefaultOptions(array())));
		$builder->prependClientTransformer(new TagTransformer($options['class']));
	}
	
	public function buildView(FormView $view, FormInterface $form)
	{
		$view->set('config', $form->getAttribute('tags-config'));
	}
}
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.