open-admin-org/open-admin

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

philips81 opened this issue · 2 comments

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.

dev branch has a novel approach to this problem

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