Get current value of SelectConstraint

Hello, I want to do some filters in my table but I'm having trouble getting current value of my select. Here is my code:
SelectConstraint::make('competences')
->label("Compétences")
->searchable()
->options(
Technology::pluck("name", "id")
)
->relationship(
name: 'competences',
titleAttribute: 'id',
modifyQueryUsing: fn (Builder $query, Forms\Get $get) => $query->where('technologie_id', $get("competences")),
)
SelectConstraint::make('competences')
->label("Compétences")
->searchable()
->options(
Technology::pluck("name", "id")
)
->relationship(
name: 'competences',
titleAttribute: 'id',
modifyQueryUsing: fn (Builder $query, Forms\Get $get) => $query->where('technologie_id', $get("competences")),
)
My table competences has this fields: id, technologie_id, candidat_id, annee Thank you in advance for yours responses !
4 Replies
Moudjames23
Moudjames23OP12mo ago
Hello ?
bernhard
bernhard12mo ago
And what is the problem? Doesn't $get("competences")) contain the correct value?
Moudjames23
Moudjames23OP12mo ago
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
No I have this error
bernhard
bernhard12mo ago
Ok. so $get isn't working on this function. Maybe you can't use relationship method here. Isn't it weird to use options and relationshipat the same time? I haven't used SelectConstraint yet, maybe you have to use the getSearchResultsUsing and getOptionLabelsUsing
Want results from more Discord servers?
Add your server