form-extensions
form-extensions copied to clipboard
Upgrade Datetime library
Feature Request
We are somehow stuck with the DateTime form type, since it is coupled with the library we are using at the frontend to render it:
https://github.com/Eonasdan/bootstrap-datetimepicker/ -> version 3.1.3
Not only is outdated (there is a version 4, 5, 6 on that repository), but also it got a name change, at least one major rewrite, some options changed a lot, etc...
Also there is another problem here, the form type is defined here, but the library is added here: https://github.com/sonata-project/SonataAdminBundle/tree/4.x/assets/vendor which is a problem because:
- Can't be added via package.json since that older version does not provide the required assets
- Can't be upgraded since there is a circular dependency hidden: Form extension requires the js + css on admin, and admin requires the form type here.
I think we should find a solution before release 2.0, wdyt @VincentLanglet ?
There are also some really old PRs and issues on CoreBundle (when everything was together):
https://github.com/sonata-project/SonataCoreBundle/issues/138 https://github.com/sonata-project/SonataCoreBundle/pull/149
I see two solutions:
- Moving the DateTimeType to SonataAdmin.
- Adding the JS/CSS to the form-extension library.
I prefer the second solution ; do you think it's possible ?
The first option involves some / lot of classes, since there are multiple types related to "dates"
The second option I like it, but I am not sure how to do it. Should we expose a raw css/js file and then on the admin we capture it with encore and add it to the build?
I add a third option.
- Make this library agnostic of the css/js part, and have something on AdminBundle that overrides it to show a pretty date picker
Make this library agnostic of the css/js part, and have something on AdminBundle that overrides it to show a pretty date picker
I don't see how a DatePickerType
will be agnostic of the datepicker library. To me it's the main purpose of this Type.
Should we expose a raw css/js file and then on the admin we capture it with encore and add it to the build?
Cant we have webpack on this project to build css/js, and then we add the file here: https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/DependencyInjection/Configuration.php#L637
We have to make sure we remain compatible with both v1 and v2 of this bundle, but yes I think it can be done that way.
First part of the issue is solved (well we need to integrate it with AdminBundle). Now we need to merge to branch v2 and upgrade the library.