malzariey / filament-daterangepicker-filter

MIT License
79 stars 39 forks source link

Applying a format to the DateRangePicker field has no effect #71

Closed mrstu84 closed 3 months ago

mrstu84 commented 3 months ago

I am using the date picker as a field (and not a filter) with displayFormat set to DD-MM-YYY and format set to Y-m-d. Each time the date range is return in the same format as the displayFormat, rather than format.

For example:

When filtering between 01-01-1970 and 01-01-2024, here's my form schema -

DateRangePicker::make('date_range')
    ->label('Select date range')
    ->displayFormat('DD-MM-YYYY')
    ->format('Y-m-d'),

And the value is returned as 01-01-1970 - 01-01-2024, rather than the expected value of 1970-01-01 - 2024-01-01.

malzariey commented 3 months ago

format is used to define the date for Carbon to read from Javascript (Used mostly in query or default values) , it should match the displayFormat in (PHP format style).

In your case just use displayFormat.

mrstu84 commented 2 months ago

Thank you for coming back to me.

I would like the value to display as 01-01-1970 - 01-01-2024 in the input field and then be submitted to PHP as 1970-01-01 - 2024-01-01, as mentioned in my original comment. I don't think you suggestion facilitates this.

malzariey commented 2 months ago

Do you mean you want to save the value in a different format to database?

On Wed, May 1, 2024, 10:23 AM Stewart Doxey @.***> wrote:

Thank you for coming back to me.

I would like the value to display as 01-01-1970 - 01-01-2024 in the input field and then be submitted to PHP as 1970-01-01 - 2024-01-01, as mentioned in my original comment. I don't think you suggestion facilitates this.

— Reply to this email directly, view it on GitHub https://github.com/malzariey/filament-daterangepicker-filter/issues/71#issuecomment-2088086318, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIPCALJ52IJ5YNYYOJGSSSDZACJ7JAVCNFSM6AAAAABGYPDUL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBYGA4DMMZRHA . You are receiving this because you modified the open/close state.Message ID: @.*** .com>

mrstu84 commented 2 months ago

Yes, that's correct. Maybe I am misunderstanding the documentation but I have read it that you can display one format in the input field and then submit that to the codebase and database in a different format. Hence the displayFormat and format attributes.

malzariey commented 2 months ago

Sorry at the moment, the feature is not available .

On Wed, May 1, 2024, 10:30 AM Stewart Doxey @.***> wrote:

Yes, that's correct. Maybe I am misunderstanding the documentation but I have read it that you can display one format in the input field and then submit that to the codebase and database in a different format. Hence the displayFormat and format attributes.

— Reply to this email directly, view it on GitHub https://github.com/malzariey/filament-daterangepicker-filter/issues/71#issuecomment-2088092411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIPCALJ7E2CAZ5SMCNVVCU3ZACK3DAVCNFSM6AAAAABGYPDUL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBYGA4TENBRGE . You are receiving this because you modified the open/close state.Message ID: @.*** .com>

mrstu84 commented 2 months ago

My misunderstanding. Thank you for coming back to me!