F
Filamentβ€’11mo ago
mamamia

Visible On Edit

how do i make input visible only on edit with the $record->status = true?
Forms\Components\Select::make('project_manager_id')
->label(__('Project Manager'))
->visibleOn('edit')
->searchable()
->options(fn() => User::all()->pluck('name', 'id')->toArray())
->default(fn() => auth()->user()->id)
->required(),
Forms\Components\Select::make('project_manager_id')
->label(__('Project Manager'))
->visibleOn('edit')
->searchable()
->options(fn() => User::all()->pluck('name', 'id')->toArray())
->default(fn() => auth()->user()->id)
->required(),
6 Replies
JC
JCβ€’11mo ago
->visible(fn(?Model $record) => $record->status) try this
mamamia
mamamiaOPβ€’11mo ago
thank you for your answer but when i tried it "visible" is not working when there is "visibleOn", so how do i know its on edit inside "visible"?
Matthew
Matthewβ€’11mo ago
try: ->visible(fn ($livewire, $record) => $livewire instanceof EditRecord && $record->status) This should work πŸ™‚
mamamia
mamamiaOPβ€’11mo ago
Awesome! it worked perfectly
Matthew
Matthewβ€’11mo ago
perfect
Want results from more Discord servers?
Add your server