Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3k stars 880 forks source link

Wrong date in calendar operations new entry #5465

Closed miquelangeld closed 4 months ago

miquelangeld commented 4 months ago

Creating a new entry using Calendar Operations the date in the form is always today's date, not the one selected in the calendar.

I removed the default value in my Create Operation but same result

CRUD::addField([   // date_range
            'name' => 'start,end', // db columns for start_date & end_date
            'label' => 'Fechas de reserva',
            'type' => 'date_range',
            //'default' => [Carbon::now()->startOfDay(), Carbon::now()->endOfDay()],
            'date_range_options' => [
                'drops' => 'down', // can be one of [down/up/auto]
                'timePicker' => true,
                'locale' => ['format' => 'DD/MM/YYYY HH:mm'],
            ],
        ]);

I expected that the date on the form is the same as the day from which I created the entry.

karandatwani92 commented 4 months ago

Hey @pxpm

I just tested the date_range, which works fine for me. Can you suggest something here?

miquelangeld commented 4 months ago

Hi @karandatwani92 if you select for example day 13th in calendar and try to create an entry from there in the form the date selector use the 13th? or 11th

karandatwani92 commented 4 months ago

Yes I choose different dates & time image

miquelangeld commented 4 months ago

I think maybe I didn't make myself clear, I mean if in the form the date that appears by default is the same as the day in the calendar.

If I try to create a new entry from calendar

image

I expect the default date in the select to be the same as in the calendar cell from I create the entry.

But the default is always "today" and not 20/03/2024 But maybe I expect behavior that is not as designed. It's not a big deal, but I think the date start should be 20/03/2024 in the form.

image

karandatwani92 commented 4 months ago

Now I get it. You are right... I'll test the user experience with calendar operation and report a list of missing features to improve the experience. This would give our patch team clarity on pushing the fixes.

I'll include this one for sure. Thanks for reporting @miquelangeld

karandatwani92 commented 4 months ago

Hey @miquelangeld

I just noticed this feature was always there. Use the following to get the selected date & time:

CRUD::field('start')->value(request()->start);
CRUD::field('end')->value(request()->end);

I also found a bug with the start value on the month view, which I have already reported. I'll update the status on this thread once it's solved.

Feel free to reopen the issue if it still needs to be solved!