@@ -154,12 +154,17 @@ protected function showListWithFilter(Request $request, string $template, ?calla
154154 $ filter_changer ($ filter );
155155 }
156156
157- $ filterForm = $ this ->createForm (PartFilterType::class, $ filter , ['method ' => 'GET ' ]);
158- if ($ form_changer !== null ) {
159- $ form_changer ($ filterForm );
160- }
157+ //If we are in a post request for the tables, we only have to apply the filter form if the submit query param was set
158+ //This saves us some time from creating this complicated term on simple list pages, where no special filter is applied
159+ $ filterForm = null ;
160+ if ($ request ->getMethod () !== 'POST ' || $ request ->query ->has ('part_filter ' )) {
161+ $ filterForm = $ this ->createForm (PartFilterType::class, $ filter , ['method ' => 'GET ' ]);
162+ if ($ form_changer !== null ) {
163+ $ form_changer ($ filterForm );
164+ }
161165
162- $ filterForm ->handleRequest ($ formRequest );
166+ $ filterForm ->handleRequest ($ formRequest );
167+ }
163168
164169 $ table = $ this ->dataTableFactory ->createFromType (PartsDataTable::class, array_merge (
165170 ['filter ' => $ filter ], $ additional_table_vars ),
@@ -186,7 +191,7 @@ protected function showListWithFilter(Request $request, string $template, ?calla
186191
187192 return $ this ->render ($ template , array_merge ([
188193 'datatable ' => $ table ,
189- 'filterForm ' => $ filterForm ->createView (),
194+ 'filterForm ' => $ filterForm? ->createView(),
190195 ], $ additonal_template_vars ));
191196 }
192197
0 commit comments