Closed adriallongarriu closed 5 months ago
Hey @adriallongarriu
The problem was the format.
I created ranges with the following format:
CRUD::field([
'name' => 'start_date,end_date',
'label' => 'Event Date Range',
'type' => 'date_range',
'date_range_options' => [
'ranges' => [
trans('backpack::crud.today') => [\Carbon\Carbon::now()->startOfDay()->format('m/d/Y'), \Carbon\Carbon::now()->startOfDay()->format('m/d/Y')],
trans('backpack::crud.yesterday') => [\Carbon\Carbon::now()->subDay()->startOfDay()->format('m/d/Y'), \Carbon\Carbon::now()->subDay()->endOfDay()->format('m/d/Y')],
]
]
]);
Hey @adriallongarriu
The problem was the format.
I created ranges with the following format:
CRUD::field([ 'name' => 'start_date,end_date', 'label' => 'Event Date Range', 'type' => 'date_range', 'date_range_options' => [ 'ranges' => [ trans('backpack::crud.today') => [\Carbon\Carbon::now()->startOfDay()->format('m/d/Y'), \Carbon\Carbon::now()->startOfDay()->format('m/d/Y')], trans('backpack::crud.yesterday') => [\Carbon\Carbon::now()->subDay()->startOfDay()->format('m/d/Y'), \Carbon\Carbon::now()->subDay()->endOfDay()->format('m/d/Y')], ] ] ]);
Tested and it works but i don't undestend why. Why need this specified date format and why in the filters\date_range.blade.php
is using other format.
I checked https://www.daterangepicker.com/ and not specified a format. And is using moment()
.
I think the correct solution would be to implement the same change that exists in filters\date_range.blade.php
and transform the dates to moment(). It does not imply a new dependency because it is already being used inside backpack and it will be more robust as it works with more date formats.
@pxpm could you take a look at this issue. I believe it's a bug and the correct solution will be implementing the same change as it is done in the \filters\date_range.blade.php
and transform the dates to moment js.
Plus the translation is still the wrong.
I would have made a pull request but this file is in the pro
Hey @adriallongarriu hope to find you well 🙏
Thanks for the ping, and sorry for the delay, we have been super busy adding Laravel 11 support to all our packages.
I've released PRO 2.1.11 with the fix, let me know if you are still experiencing issues 🙏
Cheers
Bug report
What I did
Use ranges options in a date_range. I wanted the same options as a filter an copy the seme config as
vendor\backpack\pro\resources\views\filters\date_range.blade.php
My code:
What I expected to happen
Be able to select a predefined date range
What happened
On clicking any range the date is invalid and it's impossible to select any date![image](https://github.com/Laravel-Backpack/CRUD/assets/20278289/fa506f33-9f4e-45e1-9fb2-5c4a5504f518)
What I've already tried to fix it
config('backpack.base.default_date_format')
is invalid for backpack v6. The key was changed to file ui.I override the date_range.blade.php and add the folowing code:
Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there? YESBackpack, Laravel, PHP, DB version
When I run![image](https://github.com/Laravel-Backpack/CRUD/assets/20278289/f2201a85-d11a-48fd-a80e-337bbb5a430f)
php artisan backpack:version
the output is: