Skip to content

Commit

Permalink
Merge pull request #23 from sunnysideup/patch-1
Browse files Browse the repository at this point in the history
API: allow Silverstripe 5.0
  • Loading branch information
nathancox authored Apr 17, 2024
2 parents 4fce857 + 6553e51 commit 9375920
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
}
},
"require": {
"silverstripe/framework": "~4.0"
"silverstripe/framework": "^4.0 || ^5.0"
}
}
6 changes: 4 additions & 2 deletions src/forms/HasOneAutocompleteField.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class HasOneAutocompleteField extends FormField

protected $clearButtonEnabled = false;

protected $sourceObject;

/**
* Variable that sets the autocomplete delay
*
Expand Down Expand Up @@ -118,7 +120,7 @@ public function search(HTTPRequest $request)
$json = $this->processResults($results);
}

return Convert::array2json($json);
return json_encode($json);
}

/**
Expand All @@ -128,7 +130,7 @@ public function search(HTTPRequest $request)
*/
protected function getResults($query)
{
$searchFields = ($this->getSearchFields() ?: singleton($this->sourceObject)->stat('searchable_fields'));
$searchFields = ($this->getSearchFields() ?: singleton($this->sourceObject)->config()->get('searchable_fields'));

if(!$searchFields) {
throw new Exception(
Expand Down

0 comments on commit 9375920

Please sign in to comment.