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

Did you find this page helpful?