Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Form/Type/TagType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

use Symfony\Component\OptionsResolver\OptionsResolver;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Symfony\Component\OptionsResolver\OptionsResolver;

needed instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right, I forgot to add it;

use Symfony\Component\Validator\Constraints\NotBlank;

class TagType extends AbstractType
Expand Down Expand Up @@ -34,7 +33,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
;
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually to have OptionsResolver to be available here

{
$resolver->setDefaults(array(
'data_class' => $this->tagClass
Expand Down
17 changes: 8 additions & 9 deletions Form/Type/TagsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Anh\TaggableBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Anh\Taggable\TaggableManager;
use Anh\TaggableBundle\Form\Type\TagsTransformer;
Expand Down Expand Up @@ -46,7 +45,9 @@ public function __construct(TaggableManager $taggableManager, Router $router)
protected function getTagitOptions(FormInterface $form)
{
$resolver = new OptionsResolver();
$resolver->setOptional(array(
$method = is_callable(array($resolver, 'setDefined')) ? 'setDefined' : 'setOptional';
+
+ $resolver->$method(array(
'availableTags',
'autocomplete',
'showAutocompleteOnFocus',
Expand All @@ -63,9 +64,7 @@ protected function getTagitOptions(FormInterface $form)
'placeholderText'
));

$resolver->setAllowedTypes(array(
'autocomplete' => 'array' // http://api.jqueryui.com/autocomplete/
));
$resolver->setAllowedTypes('autocomplete', 'array'); // http://api.jqueryui.com/autocomplete/

$resolver->setDefaults(array(
'allowSpaces' => true,
Expand Down Expand Up @@ -125,7 +124,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setOptional(array(
'autocomplete', // type of autocomplete
Expand All @@ -139,9 +138,9 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
* static - all tags passed via attribute (limited to 100 tags)
* custom - no tags will be provided from db (custom list of tags may be passed by setting ['tag-it']['availableTags'])
*/
$resolver->setAllowedValues(array(
'autocomplete' => array('dynamic', 'static', 'custom')
));
$resolver->setAllowedValues('autocomplete', array(
'dynamic', 'static', 'custom'
));
$resolver->setDefaults(array(
'autocomplete' => 'dynamic'
));
Expand Down