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.6 Replies
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?
theres no way to truly prevent the data from being altered, hence why is isnt returned
Solution
you can chain ->disabled()->dehydrated() to make it return
Thanks!
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.
Sorry for this, won't do it again