From d68d95a915413f1d37bf8a5e833718a8537f8bc1 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 4 Nov 2017 00:19:16 -0700 Subject: [PATCH] =?UTF-8?q?Fixed=20-=20Added=20a=20=E2=80=9Cclear=20select?= =?UTF-8?q?ion=E2=80=9D=20option=20to=20select2=20ajax=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Transformers/SelectlistTransformer.php | 5 ++++- resources/lang/en/general.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Transformers/SelectlistTransformer.php b/app/Http/Transformers/SelectlistTransformer.php index 54b55122fc..6aac737b07 100644 --- a/app/Http/Transformers/SelectlistTransformer.php +++ b/app/Http/Transformers/SelectlistTransformer.php @@ -19,7 +19,7 @@ class SelectlistTransformer public function transformSelectlist (LengthAwarePaginator $select_items) { - $items_array = []; + // Loop through the paginated collection to set the array values foreach ($select_items as $select_item) { @@ -32,6 +32,9 @@ class SelectlistTransformer } + // This is weird and awful, but the only way I can find to allow the user to + // clear the selection - @snipe + array_unshift($items_array, ['id' =>'', 'text'=> trans('general.clear_selection')]); $results = [ 'items' => $items_array, 'pagination' => diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 854787ed91..c753a311c3 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -40,6 +40,7 @@ 'checkout' => 'Checkout', 'city' => 'City', 'click_here' => 'Click here', + 'clear_selection' => 'Clear Selection', 'companies' => 'Companies', 'company' => 'Company', 'component' => 'Component',