Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autocompleter and symfony.2.7? #406

Open
scottshipman opened this issue Jul 30, 2015 · 4 comments
Open

autocompleter and symfony.2.7? #406

scottshipman opened this issue Jul 30, 2015 · 4 comments

Comments

@scottshipman
Copy link

I get the following error when I implement genemu_jqueryautocompleter_entity, but no errors when I implement genemu_jqueryautocomplete_entity. The salesAgent and secondaryContact fields are identical definitions, and swapping fields makes no difference.

Catchable Fatal Error: Argument 1 passed to Genemu\Bundle\FormBundle\Form\Core\DataTransformer\ChoiceToJsonTransformer::__construct() must implement interface Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface, instance of Symfony\Component\Form\ChoiceList\LegacyChoiceListAdapter given, called in /srv/www/Toolkit/vendor/genemu/form-bundle/Genemu/Bundle/FormBundle/Form/JQuery/Type/AutocompleterType.php on line 46 and defined

$builder
            //works
            ->add('salesAgent', 'genemu_jqueryautocomplete_entity', array(
                'required' => false,
                'class' => 'MyApp\UserBundle\Entity\User',
                'route_name' => 'retrieve_salesagent_name',
                'data_class' => 'MyApp\UserBundle\Entity\User'
            ))
            // generates error
            ->add('secondaryContact', 'genemu_jqueryautocompleter_entity', array(
              'class' => 'MyApp\UserBundle\Entity\User',
              'required' => false,
              'route_name' => 'retrieve_salesagent_name',
              'data_class' => 'MyApp\UserBundle\Entity\User',
              'multiple' => true,
            ))

using symfony v 2.7
genemu/form-bundle dev-master (2.3.x-dev)

@wetternest
Copy link

same here, using genemu/form-bundle v2.2.2 with symfony v2.7.3

@aureliengiry
Copy link

Yes, I have the same issue. It's because Choice form has been completely refactored in Symfony 2.7 http://symfony.com/blog/new-in-symfony-2-7-choice-form-type-refactorization

In class, Genemu\Bundle\FormBundle\Form\Core\DataTransformer, now, $choiceList is an instance of LegacyChoiceListAdapter

this is a beginning of fix:

use Symfony\Component\Form\ChoiceList\LegacyChoiceListAdapter;

  /**
     * Constructs
     *
     * @param ArrayChoiceList $choiceList
     * @param boolean         $ajax
     */
    public function __construct($choiceList, $ajax = false, $widget = 'choice', $multiple = false)
    {
        if ($choiceList instanceof LegacyChoiceListAdapter){
            $this->choiceList = $choiceList->getAdaptedList();
        }
        else if($choiceList instanceof ChoiceListInterface){
            $this->choiceList = $choiceList;
        }

        $this->ajax = $ajax;
        $this->multiple = $multiple;
        $this->widget = $widget;
    }

I took exemple on Sonata Admin bundle (Sonata\AdminBundle\Form\DataTransformer).
But I have now another error.
Notice: Undefined offset: 1 on file in vendor/symfony/symfony/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php at line 213

regards,

@lealceldeiro
Copy link

Please, if anyone find out how to solve this, let us know. I'm having the same problem with this bundle with Symfony 2.7.7.

Regards.

@webdevilopers
Copy link

Should be closed @genemu in favor of #412

Current workaround by @aimeric:
#412 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants