Specific partly output of a text column.I know the ->limit(50) method.I need a
I know the ->limit(15) method. But i need another output. E.g. the original value is "A1234567" and I want to output "A67" Something like that:
```
$string = 'A1234567'
$string2 = '**'
strlen($string)
$string3 = $string2($string, 0 , strlen($string) - 3)
echo substr($string, 0, 1) . $string3 . substr($string, -2);
output: 'A*67'
```
But how in filament. Probably something with formatStateUsing.
13 Replies
It's hard to tell what you want, since you didn't use code formatting and the formatting of your message was messed up
Yes, this is the right way. The example works for me in Tables\Columns but not in Forms\Components. Is that common?
Do you have a help for that? How is the tag for code. Tab right, such as in mkdocs, doesnt work here.
are you using formatStateUsing?
No. I got the error msg: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
where?
It’s triple backticks. See #✅┊rules
If i put the exmple code in Forms/Components;
Not yet. I have to dive deeper in that. the type of coding is new to me. thanks.
I got it. perhaps too complicated?
´´´´
Tables\Columns\TextColumn::make('token')
->state(function (Flexquery $record): string {
$len = str()->length($record->token);
return str()->mask($record->token . '', '*', -$len + 1, $len - 3);
}),
´´´´
Th einput is A123456789 and the output is A**89. Thats what i want.
You should use
->formatStateUsing
not ->state
Ok why. Because a string?
Ok, so i dont need the . ''
´´´ Tables\Columns\TextColumn::make('token')
->formatStateUsing(function (Flexquery $record): string {
$len = str()->length($record->token);
return str()->mask($record->token, '*', -$len + 1, $len - 3);
}),
´´