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

Uncaught SyntaxError: Identifier 'elm' has already been declared in vendor\open-admin-org\open-admin\src\Form\Field\Select.php #157

Open
philips81 opened this issue Feb 26, 2024 · 2 comments

Comments

@philips81
Copy link

philips81 commented Feb 26, 2024

Hi,
in the file vendor\open-admin-org\open-admin\src\Form\Field\Select.php
you need to change the declaration of the elm variable (lines 120 and 231) from let elm to var elm.
In this way it is possible to manage multiple cascading selects.

@pnghai
Copy link

pnghai commented Mar 8, 2024

dev branch has a novel approach to this problem

@whydesign
Copy link

whydesign commented Aug 12, 2024

Otherwise, if you do not want to use the dev branch, you can override the select class file in your composer.json.

Copy the Select.php file from vender to app
From: vendor/open-admin-org/open-admin/src/Form/Field/Select.php
To: app/Override/open-admin-org/open-admin/src/Form/Field/Select.php

Make your Changes in the Select.php class file
On line 120:

var elm = document.querySelector("{$this->getElementClassSelector()}");

And on line 231:

let elm = document.querySelector("{$this->getElementClassSelector()}");

Edit your composer.json like this:

"autoload": {
        "psr-4": {
            "App\\": "app/",
            "OpenAdmin\\Admin\\Form\\Field\\": "app/Override/open-admin-org/open-admin/src/Form/Field/"
        },
        "exclude-from-classmap": ["vendor/open-admin-org/open-admin/src/Form/Field/Select.php"],
        "files": ["app/Override/open-admin-org/open-admin/src/Form/Field/Select.php"]
    },

Run autoload dump

composer dump-autoload

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

3 participants