TextEntry when value is null

TextEntry::make('strap')
->columnSpanFull()
->getStateUsing(function (Product $record) {
ray($record);
return $record->strap === 1 ? 'Ja' : 'Nee';
})
TextEntry::make('strap')
->columnSpanFull()
->getStateUsing(function (Product $record) {
ray($record);
return $record->strap === 1 ? 'Ja' : 'Nee';
})
Why doesn't this work when the value of strap is null?
Solution:
It seems to work now. Don't know why it wasn't working before
Jump to solution
6 Replies
krekas
krekas10mo ago
Maybe because you are strict checking? Also, I think you should use formatStateUsing
Dennis Koch
Dennis Koch10mo ago
Nope. getStateUsing() is correct here, because null wouldn't be passed to formatStateUsing
JJSanders
JJSandersOP10mo ago
So any idea why it wouldnt work?
LeandroFerreira
LeandroFerreira10mo ago
Isn't 'Nee' displayed?
Solution
JJSanders
JJSanders10mo ago
It seems to work now. Don't know why it wasn't working before
Dennis Koch
Dennis Koch10mo ago
Nee 😅

Did you find this page helpful?