auth()->user-> not filled in form

I have an issue with username not being filled neither with deafult() or reactive(). It looks like auth()->user()->name not being used at all. There is no error whatsoever shown, just data being ignored. Currently i am filling those with mutateFormDataBeforeSave, but i would like to have it in form directly. Forms\Components\Checkbox::make('checked') ->label('Checked') ->reactive() ->afterStateUpdated(fn ($state, callable $set) => $state === true ? $set('checked_by', auth()->user()->name) : $set('checked_by', null)) ->afterStateUpdated(fn ($state, callable $set) => $state === true ? $set('checked_time', now()->toDateTimeString()) : $set('checked_time', null)), Checked time works as it should, i have issue only with checked_by field.
Solution:
you can chain ->disabled()->dehydrated() to make it return
Jump to solution
6 Replies
DariusIII
DariusIIIOP16mo ago
Ok, figured it out. If the form field is disabled it does not send the data at all. I was under impression that disabled means that data cannot be altered, not that data is being completely ignored. @Dan Harrin Can you confirm?
Dan Harrin
Dan Harrin16mo ago
theres no way to truly prevent the data from being altered, hence why is isnt returned
Solution
Dan Harrin
Dan Harrin16mo ago
you can chain ->disabled()->dehydrated() to make it return
DariusIII
DariusIIIOP16mo ago
Thanks!
Dan Harrin
Dan Harrin16mo ago
but its not truly safe as you can still change the value in JS also, please please don't @ me, im not the only one who can answer questions.
DariusIII
DariusIIIOP16mo ago
Sorry for this, won't do it again
Want results from more Discord servers?
Add your server