syedahnb
Explore posts from serversNeed 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);
}
6 replies