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

Date field layout on CP submissions view not using date picker #2157

Open
jamesmacwhite opened this issue Nov 24, 2024 · 8 comments
Open

Date field layout on CP submissions view not using date picker #2157

jamesmacwhite opened this issue Nov 24, 2024 · 8 comments

Comments

@jamesmacwhite
Copy link
Contributor

jamesmacwhite commented Nov 24, 2024

Describe the bug

I've noticed this between Formie 1.x and Formie 3. Any date field on the CP submission view is represented as the database date/time string value, without the date picker.

Current field in Formie 1:

(Ignore LastPass it likes to get involved on most fields...)

image

Current field in Formie 3:

image

The data is correct, but from a human representation perspective, it would be nice if the submission view used the date picker in the locale set i.e. like Craft does with date fields on entries.

Steps to reproduce

  1. Create a date field on a form.
  2. Create a submission with a date field populated.
  3. View the submission in the CP backend.
  4. See the representation in the backend of the date field.

Form settings

N/A

Craft CMS version

5.5.3

Plugin version

3.0.12

Multi-site?

No response

Additional context

No response

@engram-design
Copy link
Member

What's your exact field settings for this field? It shouldn't be showing that for any combination:

image

I actually think there might be a JS error that's preventing the date picker from kicking in. We populate the date picker component with a proper ISO-formatted date, but the date picker should kick in to format that visually. Can you confirm any JS errors?

@jamesmacwhite
Copy link
Contributor Author

Ah interesting.

I'm wondering if it is because of using the date/time events to set additional formats e.g.

Event::on(Date::class,
            Date::EVENT_MODIFY_DATE_FORMAT,
            static function(ModifyDateTimeFormatEvent $event) {
                $event->dateFormat = 'd/m/Y';
            }
        );

        Event::on(Date::class,
            Date::EVENT_MODIFY_TIME_FORMAT,
            static function(ModifyDateTimeFormatEvent $event) {
                $event->timeFormat = 'g:i A';
            }
        );

        Event::on(Date::class,
            Date::EVENT_REGISTER_TIME_FORMAT_OPTIONS,
            static function(RegisterDateTimeFormatOpionsEvent $event) {
                $event->options[] = ['label' => '1:00 PM (g:i AM/PM)', 'value' => 'g:i A'];
            }
        );

I'll do some testing.

@jamesmacwhite
Copy link
Contributor Author

jamesmacwhite commented Nov 26, 2024

Looks like it might be related to the AssetBundle throwing a 404 when viewing the submission backend, when checking the console.

https://craftcms.com/knowledge-base/cloud-plugin-development#asset-bundles

Craft Cloud which we run our staging and live environment on publishes all asset bundles at build/deploy through the CDN path.

There is note here: Publishing one-off or ad-hoc assets at runtime is not supported on Cloud.

Not sure if this is happening anywhere?

The AssetBundle paths that are throwing a 404:

https://cdn.craft.cloud/d10b9526-496f-4cd6-a8ff-319f00317266/builds/9d93248e-6e98-4911-95c8-5d3855780b98/cpresources/craft-web-assets-datepickeri18n-dist/datepicker-en-GB.js?v=1732318185

https://cdn.craft.cloud/d10b9526-496f-4cd6-a8ff-319f00317266/builds/9d93248e-6e98-4911-95c8-5d3855780b98/cpresources/verbb-formie-web-assets-frontend/dist/js/formie.js?v=1731753441

I can't see any 404 errors happening on the front-end interestingly though. The advanced date with Flatpickr is functioning on the front end, only on the CP backend does it appear to be failing due to the AssetBundle 404.

@jamesmacwhite
Copy link
Contributor Author

jamesmacwhite commented Nov 26, 2024

Comparing the two, there appears to be some slight path variance on the front-end compared to the back-end:

Working paths on the front end:

https://cdn.craft.cloud/d10b9526-496f-4cd6-a8ff-319f00317266/builds/9d93248e-6e98-4911-95c8-5d3855780b98/cpresources/verbb-formie-web-assets-frontend-dist/js/fields/date-picker.js?v=1731753441
https://cdn.craft.cloud/d10b9526-496f-4cd6-a8ff-319f00317266/builds/9d93248e-6e98-4911-95c8-5d3855780b98/cpresources/verbb-formie-web-assets-frontend-dist/js/formie.js?v=1731753441

CP submission backend (404):

https://cdn.craft.cloud/d10b9526-496f-4cd6-a8ff-319f00317266/builds/9d93248e-6e98-4911-95c8-5d3855780b98/cpresources/craft-web-assets-datepickeri18n-dist/datepicker-en-GB.js?v=1732318185
https://cdn.craft.cloud/d10b9526-496f-4cd6-a8ff-319f00317266/builds/9d93248e-6e98-4911-95c8-5d3855780b98/cpresources/verbb-formie-web-assets-frontend/dist/js/formie.js?v=1731753441

The differences appear to be:

  • verbb-formie-web-assets-frontend/dist instead of verbb-formie-web-assets-frontend-dist
  • craft-web-assets-datepickeri18n-dist instead of verbb-formie-web-assets-frontend-dist

What do we think, Craft Cloud bug?

@engram-design
Copy link
Member

Ah, so yes this is probably related to Craft Cloud and how they handle assets. I'll look into it further.

The formie.js file is going to try and lazy-load other JS in, but seeing as though that 404's, it can't do that. The datepicker-en-GB.js would be for Craft's date picker, not something we bundle with Formie.

@jamesmacwhite
Copy link
Contributor Author

It will be for sure. All of the asset bundles are redirected to the CDN path during the build, interesting that it happens for the CP but not front-end which I guess is the better scenario.

Would you like me to raise a support case with Craft Cloud, happy to summarise the findings for further review?

@engram-design
Copy link
Member

Yeah might be worthwhile, I'll investigate on my end!

@jamesmacwhite
Copy link
Contributor Author

Thanks Josh, will do and I'll keep you updated.

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

2 participants