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
krekas14mo ago
Maybe because you are strict checking? Also, I think you should use formatStateUsing
Dennis Koch
Dennis Koch14mo ago
Nope. getStateUsing() is correct here, because null wouldn't be passed to formatStateUsing
JJSanders
JJSandersOP14mo ago
So any idea why it wouldnt work?
LeandroFerreira
LeandroFerreira14mo ago
Isn't 'Nee' displayed?
Solution
JJSanders
JJSanders14mo ago
It seems to work now. Don't know why it wasn't working before
Dennis Koch
Dennis Koch14mo ago
Nee 😅

Did you find this page helpful?