Hide field in form
Hi, I am creating different resources, depending on the type of role, but, I want it to NOT SHOW, just send a default role.
This is my code:
Select::make('roles')
->relationship('roles', 'name')
->default(Role::where('name', 'student')->first()->id)
->preload(),

8 Replies
use Filament\Forms\Get;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\TextInput;
Checkbox::make('is_company')
->live()
TextInput::make('company_name')
->hidden(fn (Get $get): bool => ! $get('is_company'))
Sorry, I can't find a way to hide it, I checked the documentation, but I didn't succeed.
Do you have any other ideas?
I have placed this, but, if I hide the select, it doesn't matter, the role is not saved.


Would you like to remove the select and save a default role?
Yes, I just want the default Student role to be saved.
But, I don't want it to be displayed on the form. I want the user to be created automatically with the student role.
You can save it manually using this
https://filamentphp.com/docs/3.x/panels/resources/creating-records/#customizing-the-creation-process