FranDev
FranDev
FFilament
Created by FranDev on 3/5/2024 in #❓┊help
i need to pass a form component as parameter to another form component
I need the value of a select form component when a given input form component is not hidden, like this:
Select::make('client_category')
->options($categories->pluck('descripcion', 'id')->toArray())
->searchable()
->live(onBlur: true)
->default($default),
TextInput::make('name')
->hidden(function (Get $get, Set $set, Component $component):bool {
if($get('client_category') != null) {
dd($component); //i need the $component from the select
return false;
}
return true;
})
Select::make('client_category')
->options($categories->pluck('descripcion', 'id')->toArray())
->searchable()
->live(onBlur: true)
->default($default),
TextInput::make('name')
->hidden(function (Get $get, Set $set, Component $component):bool {
if($get('client_category') != null) {
dd($component); //i need the $component from the select
return false;
}
return true;
})
In the documentation: https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-current-form-component-instance, i tried this:
use Filament\Forms\Components\Component;

function (Component $component) {
// ...
}
use Filament\Forms\Components\Component;

function (Component $component) {
// ...
}
but that gives me the current form component, what i need is the component of another form field, because i want to extract the text present on the selected option of the select field If you can help me achieve this, or guide me to the right way.. thanks in advance!
2 replies