Datepicker error

Hello devs I am encountering a problem with Datepicker It was working fine but it suddenly returns undefined anyone encountering the same?
58 Replies
Kenneth Sese
Kenneth Sese2y ago
Have you updated to the latest version? v.40? v.39 had some issues with the datepicker. Could be related.
Lambertn33
Lambertn33OP2y ago
@kennethsese you mean 2.17.40?
Kenneth Sese
Kenneth Sese2y ago
Yes
Lambertn33
Lambertn33OP2y ago
I have 2.17.40 but still not working something else i should check?
Kenneth Sese
Kenneth Sese2y ago
It was working before? Do you know what version of Filament? I’m actually off to bed…it’s super late here. Hopefully someone can pick this up now, but if not I can take a look when I’m back in the morning.
Lambertn33
Lambertn33OP2y ago
yes it was working before! my filament version is 2.17.40 sure thanks!
Kenneth Sese
Kenneth Sese2y ago
Hi! Did you get resolution on this?
Lambertn33
Lambertn33OP2y ago
Not yet
Kenneth Sese
Kenneth Sese2y ago
Ok...I'll look into it
Lambertn33
Lambertn33OP2y ago
Thank you @kennethsese this blocked me the whole day 😞
Kenneth Sese
Kenneth Sese2y ago
So the datepicker is working on my end. Can you send the code you are using. Also, have you by any chance published your views?
Lambertn33
Lambertn33OP2y ago
DatePicker::make('from') ->label('starting date') ->minDate(date('Y-m-d', strtotime('+1 day'))) ->required() ->placeholder('select the starting date') ->reactive(), DatePicker::make('to') ->label('ending date') ->required() ->placeholder('select the ending date') ->minDate(function (callable $get) { $from = $get('from'); if ($from) { return $from; } }), @kennethsese this is my codes!
Kenneth Sese
Kenneth Sese2y ago
I copied pasted that code into my project and everything worked as expected. So it's not the date picker.
Kenneth Sese
Kenneth Sese2y ago
Try npm run build And have you published your views by any chance?
Lambertn33
Lambertn33OP2y ago
No @kennethsese I didn't
Lambertn33
Lambertn33OP2y ago
should I run this?
Kenneth Sese
Kenneth Sese2y ago
No...I asked about publishing views because if you had published them before then they might not have the latest changes in them which could be causing the problem It's recommended you DONT publish Filamen't views. (What you sent was for publishing translations and config files which is fine) Did npm run dev or npm run build not help?
Lambertn33
Lambertn33OP2y ago
No they didn't 🙁 might this be related to something like node version or php version?
Kenneth Sese
Kenneth Sese2y ago
Php no. Node? Probably not. I’d try the basics: composer update php artisan filament:upgrade And just for sanity I’d check your resources/vendor folder to see if you might have published views by accident.
John
John2y ago
If you are using git, you could try to "rewind" to an earlier commit until it works again. Then go forward to identify where the trouble is coming from.
Kenneth Sese
Kenneth Sese2y ago
And then last resort, start up a new project and see if the date picker works there for you. You need to go through all the normal debug steps since it’s not a problem with the date picker. Strip out all other code in the form. Maybe there’s a conflict with a different plugin. Simply your date picker and see if that solves it. Rewind as suggested above. Start a new project and see if it works there. Unfortunately, it seems to be something with your setup that is very hard to debug from the outside.
toeknee
toeknee2y ago
You also have 16 console errors but only 1 is shown, something is wrong in your stack could be a plug-in causing it etc, as above debug usual steps
Lambertn33
Lambertn33OP2y ago
@toeknee_iom here is the full file
toeknee
toeknee2y ago
Strange that’s for sure
Lambertn33
Lambertn33OP2y ago
very strange!
awcodes
awcodes2y ago
what are your casts for 'from' and 'to'?
Lambertn33
Lambertn33OP2y ago
@awcodes I don't have any casts for them!
awcodes
awcodes2y ago
So, cast them. I think those fields are expecting a Carbon instance. Based on your code.
'from' => 'datetime',
'to' => 'date'
'from' => 'datetime',
'to' => 'date'
Kenneth Sese
Kenneth Sese2y ago
That definitely doesn't hurt to try (and they should be cast), but his problem is on create when loading the page
awcodes
awcodes2y ago
maybe hard refresh and clear broswer cache too.
toeknee
toeknee2y ago
What’s the column type too? String per chance?
Kenneth Sese
Kenneth Sese2y ago
Exactly. @lambertn33 try everything. I mean even turn your computer off and back on again Maybe it's a weird browser caching thing. Open a new private browser. Try a different browser
Lambertn33
Lambertn33OP2y ago
they are date!
toeknee
toeknee2y ago
In the txt file code you provided you are using DateTimePicker which wouldn’t have a date time value from a date column. That would explain the issue too
Lambertn33
Lambertn33OP2y ago
Well I inserted the Datetimepicker for a while to check if this can work and it failed too!
toeknee
toeknee2y ago
I give up then 🤣🤣
Lambertn33
Lambertn33OP2y ago
let me re-clone the repo @toeknee_iom @toeknee_iom @awcodes the thing is: I put Datepicker in other filament resource and it worked but It refused in CampaignResource
toeknee
toeknee2y ago
This is definitely editing right? Check the model differences Try a different browser
Kenneth Sese
Kenneth Sese2y ago
What's in your CreateCampaign file?
Lambertn33
Lambertn33OP2y ago
<?php namespace App\Filament\Resources\CampaignResource\Pages; use App\Filament\Resources\CampaignResource; use App\Models\Campaign; use App\Models\Province; use App\Models\Role; use Filament\Notifications\Notification; use Filament\Pages\Actions; use Illuminate\Support\Facades\Auth; use Filament\Resources\Pages\CreateRecord; use Illuminate\Support\Str; class CreateCampaign extends CreateRecord { protected static string $resource = CampaignResource::class; protected function getRedirectUrl(): string { return $this->getResource()::getUrl('index'); } protected function mutateFormDataBeforeCreate(array $data): array { $data['id'] = Str::uuid()->toString(); $data['manager_id'] = Auth::user()->manager->id; $data['district_id'] = Auth::user()->manager->district->id; $data['province_id'] = Province::where('id', Auth::user()->manager->district->province_id)->value('id'); //draft $data['from'] = now()->format('Y-m-d'); $data['to'] = now()->format('Y-m-d'); return $data; } protected function getCreatedNotification(): ?Notification { return Notification::make() ->success() ->title('Campaign registered') ->body('The campaign has been created successfully.'); } public function mount(): void { if (Auth::user()->role->role == Role::DISTRICT_MANAGER_ROLE) { $check = Campaign::where('manager_id', Auth::user()->manager->id) ->where('status', Campaign::ONGOING)->exists(); abort_unless($check == false, 403); } } }
awcodes
awcodes2y ago
parent::mount(); you really shouldn't be overriding mount though you should use the authorization methods to check that.
Kenneth Sese
Kenneth Sese2y ago
Confirmed. This is the problem
Lambertn33
Lambertn33OP2y ago
God bless you so much @awcodes it is working!
Kenneth Sese
Kenneth Sese2y ago
Got the same error
Lambertn33
Lambertn33OP2y ago
@kennethsese @toeknee_iom thank you so much friends!
toeknee
toeknee2y ago
How the feck did I miss that! Damn txt files 😂😂 didn’t even see a mount function 🙈
Kenneth Sese
Kenneth Sese2y ago
He only sent the Resource file first. Just now sent the CreateCampaign file @lambertn33 Glad you got it worked out
Lambertn33
Lambertn33OP2y ago
I was planning on postponing the demo that I have tomorrow lying to be sick😆
toeknee
toeknee2y ago
Ahh
Lambertn33
Lambertn33OP2y ago
but you saved my day!
Kenneth Sese
Kenneth Sese2y ago
haha!! Wow! This was critical for you then!
Lambertn33
Lambertn33OP2y ago
since Yesterday I was being blocked on this!
awcodes
awcodes2y ago
now you have to work all night to catch up. lol.
Lambertn33
Lambertn33OP2y ago
haha sure @awcodes Thanks for the support guys @awcodes @kennethsese @toeknee_iom @john.77
awcodes
awcodes2y ago
no worries. good luck with the demo.
Lambertn33
Lambertn33OP2y ago
Thanks mate!
Want results from more Discord servers?
Add your server