Need Assistance with Setting and Retrieving Filter Form Values

I need to set a value in one filter form and retrieve it in another filter here's a simplified
` public static function table(Table $table): Table
{
return $table->


->filters([

Tables\Filters\Filter::make('created_date')->form(
[
Forms\Components\DatePicker::make('created_date_from')
->prefix('Starts')
->format('d/m/Y')->placeholder("Date To")->columns(1)
->reactive()
->live()
->afterStateUpdated(function (Forms\Set $set, $state) {

$set('created_date_from',$state);
}),
Forms\Components\DatePicker::make('created_date_to')
->prefix('End')
->format('d/m/Y')->placeholder("Date From")
->default(now())->columns(1)->reactive(),
])
->query(function (Builder $query, array $data) {
||

}),||
Tables\Filters\Filter::make('table_id')
->form([


Forms\Components\Select::make('table_id')
->label('Table')

->options(function (Forms\Get $get) {
Log::info($get('created_date'));
if ( $get('created_date')) {

Log::info($get('created_date'));
dd($get('created_date'));

}


}),


])
->query(function (Builder $query, array $data): Builder {

}),
], )


->defaultPaginationPageOption(25);
}
` public static function table(Table $table): Table
{
return $table->


->filters([

Tables\Filters\Filter::make('created_date')->form(
[
Forms\Components\DatePicker::make('created_date_from')
->prefix('Starts')
->format('d/m/Y')->placeholder("Date To")->columns(1)
->reactive()
->live()
->afterStateUpdated(function (Forms\Set $set, $state) {

$set('created_date_from',$state);
}),
Forms\Components\DatePicker::make('created_date_to')
->prefix('End')
->format('d/m/Y')->placeholder("Date From")
->default(now())->columns(1)->reactive(),
])
->query(function (Builder $query, array $data) {
||

}),||
Tables\Filters\Filter::make('table_id')
->form([


Forms\Components\Select::make('table_id')
->label('Table')

->options(function (Forms\Get $get) {
Log::info($get('created_date'));
if ( $get('created_date')) {

Log::info($get('created_date'));
dd($get('created_date'));

}


}),


])
->query(function (Builder $query, array $data): Builder {

}),
], )


->defaultPaginationPageOption(25);
}
2 Replies
syedahnb
syedahnb5mo ago
Ho can i get created_date_from inside Tables\Filters\Filter::make('table_id' @awcodes if you have some time please can you guide me , how can I achieve this. Much thank full and much appreciated
awcodes
awcodes5mo ago
I’m honestly not sure how you’d do this. I don’t think Get / Set will work though. Might need to inject $livewire in the callbacks and read the filters from there. Also, please read the rules and don’t tag people if they haven’t asked you to do so.
Want results from more Discord servers?
Add your server