Let Filament decrypt database value in TextInput
I got a TextInput field in a form in Filament which is a encrypted value in the database. I have the Laravel cast
encrypted
on it in my model, but Filament does not seem to decrypt the value if you edit 🤔16 Replies
This is the TextInput:
and in my model:
Did you check it works without Filament?
Yes it does decrypt it with php artisan tinker
So if you reveal the password it's still encrypted?
It doesnt fill the value at all in Filament.
Sounds like a different issue then. What does your form look like?
Ah.... 😅 typing this I realized the issue...
Sometimes typing it out already tells you the answer 🙃
So i need to remove the hidden. Can't i unhide something for Filament?
Because I would still like to use the hidden on my model as it will also be used in other places rather than Filament 🤔
As you are using a form, you could just add it manually instead of
$model->toArray()
I am using it in Filament admin panel's form builder
I assumed you use the standalone one as you didn't select the "Panel" tag. I guess you could use some hydration hook and set
->setHidden([])
on the modelAdded the Panel tag so other people who might face the same "issue" will stumble accross this.
And thanks for the hydration tip, I will try something out with that ☑️
Thanks!
Something like this combined with
$this->getRecord()->setHidden([])
maybe?
https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-filling-the-formThat would work perfectly, although I am using a relationship field
Which does not resolve through that method
Yeah, those are kinda special, but should have similar methods
Adding this works:
This seems to be the solution, thanks for helping!
Nice.You're welcome