Get value from a Select component and pass it to a static function

I need to get the selected value from a Select component and pass it to another (static) function for filtering purposes. How can I achieve this? This is the code that holds the select functionality:"
Forms\Components\Select::make('client_id')
->columnSpanFull()
->reactive()
->label(__('strings.models.clients.single'))
->helperText('De organisatie die deze vacature plaatst')
->options(function () {
return Client::query()
->where('client_type_id', '=', 1)
->pluck('name', 'id')
->sort();
})
->searchable()
->preload()
->required(),
Forms\Components\Select::make('client_id')
->columnSpanFull()
->reactive()
->label(__('strings.models.clients.single'))
->helperText('De organisatie die deze vacature plaatst')
->options(function () {
return Client::query()
->where('client_type_id', '=', 1)
->pluck('name', 'id')
->sort();
})
->searchable()
->preload()
->required(),
This is the code that needs the value of the client_id field:
Forms\Components\Section::make('Content')
->label(__('strings.fields.job_content'))
->schema([
Forms\Components\Card::make()
->schema([
FormHelpers::ContentBlocks('content', <client_id>??),
])
])
->columnSpan(12),
Forms\Components\Section::make('Content')
->label(__('strings.fields.job_content'))
->schema([
Forms\Components\Card::make()
->schema([
FormHelpers::ContentBlocks('content', <client_id>??),
])
])
->columnSpan(12),
3 Replies
toeknee
toeknee2y ago
Use closure getters so:
Forms\Components\Section::make('Content')
->label(__('strings.fields.job_content'))
->schema([
Forms\Components\Card::make()
->schema(fn(Closure $get) => [
FormHelpers::ContentBlocks('content', $get('../client_id')),
])
])
->columnSpan(12),
Forms\Components\Section::make('Content')
->label(__('strings.fields.job_content'))
->schema([
Forms\Components\Card::make()
->schema(fn(Closure $get) => [
FormHelpers::ContentBlocks('content', $get('../client_id')),
])
])
->columnSpan(12),
Providing you have it within the same component
Daniel Plomp
Daniel PlompOP2y ago
OK, great. That worked (without the ../. Thanks!
toeknee
toeknee2y ago
Great, that means you are on the same level. you need ../ when traversing
Want results from more Discord servers?
Add your server