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

Initialize error javascript #188

Open
Saikurin opened this issue Aug 3, 2022 · 0 comments
Open

Initialize error javascript #188

Saikurin opened this issue Aug 3, 2022 · 0 comments

Comments

@Saikurin
Copy link

Saikurin commented Aug 3, 2022

When I initialize my select2 field, i have a JS error : $s2.select2 is not a function
I'm using "tetranz/select2entity-bundle": "^3.1" and I have executed bin/console assets:install

I add this line in my javascript block :

<script src="{{ asset('bundles/tetranzselect2entity/js/select2entity.js') }}"></script>

And this is my form class :

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('zone', Select2EntityType::class, [
                'class' => Zone::class,
                'primary_key' => 'id',
                'text_property' => 'name',
                'multiple' => true,
                'allow_clear' => true,
                'language' => 'fr',
                'remote_route' => 'folder_select2_zone',
            ]);
    }

I don't think it's related but this is my route 'folder_select2_zone' :

     /**
     * @Route("/folder/select2_zone", name="folder_select2_zone")
     */
    public function select2Zone()
    {
        return new JsonResponse([
            [
                'id' => 1,
                'name' => 'toto'
            ]
        ]);
    }
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

1 participant