From d76337439c991299992cee7b3dbb5ff50f68bb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2?= Date: Thu, 18 Jul 2019 18:17:54 +0200 Subject: [PATCH] Allows NULL on relationship with AJAX request (#4249) When jSelect ask for the possible relationships the response ignore the required option of the field. This will ad dback the functionality, it also prevents the output of the 'NONE' option when using the search query --- src/Http/Controllers/VoyagerBaseController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Http/Controllers/VoyagerBaseController.php b/src/Http/Controllers/VoyagerBaseController.php index e6de7930dc..a334f5107b 100644 --- a/src/Http/Controllers/VoyagerBaseController.php +++ b/src/Http/Controllers/VoyagerBaseController.php @@ -661,6 +661,14 @@ public function relation(Request $request) } $results = []; + + if (!$row->required && !$search) { + $results[] = [ + 'id' => '', + 'text' => __('voyager::generic.none'), + ]; + } + foreach ($relationshipOptions as $relationshipOption) { $results[] = [ 'id' => $relationshipOption->{$options->key},