How can I prevent a TextInput from the form from being registered or sent to the new record?

How can I prevent a TextInput from the form from being registered or sent to the new record?
14 Replies
Crater
CraterOP2y ago
TextInput ->disabled()?
Crater
CraterOP2y ago
Solved:
use Filament\Forms\Components\Hidden;

Hidden::make('code')
use Filament\Forms\Components\Hidden;

Hidden::make('code')
https://filamentphp.com/docs/2.x/forms/fields#hidden
wyChoong
wyChoong2y ago
->dehydrated(false) Hopefully you are not using this for holding some record id 😉
Crater
CraterOP2y ago
not for the id record but for autogenerators such as the slug or a code string F0001 it is right?
wyChoong
wyChoong2y ago
If it’s not required to show in the form, maybe don’t generate and hide it then Use the mutate function instead
awcodes
awcodes2y ago
Fair warning anything using a Hidden field can be mutated by the user on the front end. That's the point wyChoong is making. It should really never be used unless absolutely necessary.
wyChoong
wyChoong2y ago
mutateFormDataBeforeCreate
Crater
CraterOP2y ago
In my case, to make a new record when entering the item in the warehouse. I require the product id and the warehouse id, but since it is in a ProductsRelationManager with the ownerRecord I get the warehouse id. How can I pass the warehouse ID to the record without showing it in the form? @awcodes @wyChoong 🤔
wyChoong
wyChoong2y ago
Access ownerRecord here
Crater
CraterOP2y ago
OK, any clear example of where to use it or in what class? thx
wyChoong
wyChoong2y ago
In your relationship manager table header action
Crater
CraterOP2y ago
done. 👍

Did you find this page helpful?