Commit 6c8d0826 authored by catch's avatar catch

Issue #2254777 by m1r1k: Block category autocomplete does not work.

parent 938ac1f5
...@@ -59,7 +59,7 @@ public function autocomplete(Request $request) { ...@@ -59,7 +59,7 @@ public function autocomplete(Request $request) {
$matches = array(); $matches = array();
foreach ($this->blockManager->getCategories() as $category) { foreach ($this->blockManager->getCategories() as $category) {
if (stripos($category, $typed_category) === 0) { if (stripos($category, $typed_category) === 0) {
$matches[$category] = String::checkPlain($category); $matches[] = array('value' => $category, 'label' => String::checkPlain($category));
} }
} }
return new JsonResponse($matches); return new JsonResponse($matches);
......
...@@ -59,8 +59,8 @@ public function setUp() { ...@@ -59,8 +59,8 @@ public function setUp() {
*/ */
public function testAutocompleteSuggestions($string, $suggestions) { public function testAutocompleteSuggestions($string, $suggestions) {
$suggestions = array_map(function ($suggestion) { $suggestions = array_map(function ($suggestion) {
return String::checkPlain($suggestion); return array('value' => $suggestion, 'label' => String::checkPlain($suggestion));
}, array_combine($suggestions, $suggestions)); }, $suggestions);
$result = $this->autocompleteController->autocomplete(new Request(array('q' => $string))); $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string)));
$this->assertSame($suggestions, json_decode($result->getContent(), TRUE)); $this->assertSame($suggestions, json_decode($result->getContent(), TRUE));
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment