FilamentF
Filament3y ago
vas

field disabled on the edit page and hidden on the create new record page

hi i would like to have this field disabled on the edit page and hidden on the create new record page

                Forms\Components\TextInput::make('user_id')
                    ->required()
                    ->maxLength(255),

any idea how could i accomplish this ? thank you
Solution
        return $form
            ->schema([
                Forms\Components\TextInput::make('location')
                    ->required()
                    ->maxLength(255),
                Forms\Components\Fieldset::make('User Information')
                    ->relationship('user', 'name')
                    ->schema([
                        Forms\Components\TextInput::make('name')
                            ->disabled(fn ($livewire) => $livewire instanceof EditRecord)
                    ])->hidden(fn ($livewire) => $livewire instanceof CreateRecord),
                Forms\Components\DatePicker::make('date')
                    ->required(),
                Forms\Components\TimePicker::make('time')
                    ->required(),
                Forms\Components\FileUpload::make('attachments')
                    ->image()
                    ->maxFiles(10)
                    ->multiple()->downloadable(),
                Forms\Components\Textarea::make('description')
                    ->required()
                    ->columnSpanFull(),
                Forms\Components\Textarea::make('corrective_action')
                    ->columnSpanFull(),
            ]);
    }
tweaked 😄
Was this page helpful?