From 543bddc03fbf9dc90429d4d77dd11affaea4f356 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 25 May 2021 09:13:28 +0200 Subject: Use select_field helper for city/venue filter. --- includes/admin/views/giglog_admin_page.php | 49 ++++++++++-------------------- 1 file changed, 16 insertions(+), 33 deletions(-) (limited to 'includes/admin/views/giglog_admin_page.php') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 7de52ce..8ae30c3 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -70,45 +70,28 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_filters(): string + static function get_filters() : string { - $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities()); - $cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS ); - $selected_city = - filter_input(INPUT_POST, "selectcity", FILTER_SANITIZE_SPECIAL_CHARS) - || $cities[0]; - - $select = '
FILTER DATA: '; + $select = 'FILTER DATA:'; + $select .= \EternalTerror\ViewHelpers\select_field( + "selectcity", + array_map(fn($city) => [$city, $city], GiglogAdmin_Venue::all_cities()), + $cty, + "Select city..."); - if ( $cty && $cty!= "ALL" ) { + if ( !empty($cty) ) { //second drop down for venue - $venues = GiglogAdmin_Venue::venues_in_city($cty); - - $venue_list = array_merge( - [0, "ALL"], + $select .= \EternalTerror\ViewHelpers\select_field( + "selectvenue", array_map( - function($v) { return [$v->id(), $v->name()]; }, - $venues)); - - $selected_venue = filter_input(INPUT_POST, "selectvenue", FILTER_SANITIZE_SPECIAL_CHARS) - || $venue_list[0]; - - $select .= ''; - + fn($venue) => [$venue->id(), $venue->name()], + GiglogAdmin_Venue::venues_in_city($cty) + ), + filter_input(INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS), + "Select venue..."); } //option to select own concerts only $select .= '