yii2-extensions/datetime-picker

Multiple DatePickers Generate Duplicate Scripts Leading to JavaScript Errors

Opened this issue · 0 comments

What steps will reproduce the problem?

Render multiple instances of the DateTimePicker widget on the same page.
Ensure that each instance has a unique ID.
Observe the rendered HTML and JavaScript.

What is the expected result?

Each DateTimePicker instance should initialize independently without causing JavaScript errors due to conflicting variable declarations. The JavaScript generated for each date picker instance should be isolated to prevent conflicts.

What do you get instead?

When rendering multiple DateTimePicker instances, the generated JavaScript scripts for each date picker contain identical variable names and constants. This results in JavaScript errors such as "Uncaught SyntaxError: Identifier 'config' has already been declared" due to the redeclaration of variables. The script registration process may also cause duplicate script registrations.

Additional info

Q A
Version 0.1.0 (latest)
PHP version 8.1.12
Operating system ubuntu 23.04