Commits

Arkadiusz Dzięgiel committed 5e8ce58

added class field to tagtype

Comments (0)

Files changed (2)

Form/DataTransformer/TagTransformer.php

 
 	private $found_class = null;
 	
+	public function __construct($cls) {
+		$this->found_class = $cls;
+	}
+	
 	public function transform($tags)
 	{
 		if(empty($tags)) return null;
 		
 		$ret=array();
-		if($tags instanceof \PropelCollection){
+		if($tags instanceof \PropelCollection && is_null($this->found_class)){
 			$this->found_class = $tags->getModel();
 		}
 		if($tags instanceof \PropelCollection || is_array($tags))

Form/Type/TagsType.php

 			'removeWithBackspace' => true,
 			'minChars' => 0,
 			'maxChars' => 255, //if not provided there is no limit,
-			'placeholderColor' => '#666666'
+			'placeholderColor' => '#666666',
+			'class' => null,
 		);
 	}
 	
 		parent::buildForm($builder, $options);
 		
 		$builder->setAttribute('tags-config', array_intersect_key($options, $this->getDefaultOptions(array())));
-		$builder->prependClientTransformer(new TagTransformer());
+		$builder->prependClientTransformer(new TagTransformer($options['class']));
 	}
 	
 	public function buildView(FormView $view, FormInterface $form)