From 7e246b3f7750d0cfe03dd47bcc9176edf87b0dbb Mon Sep 17 00:00:00 2001 From: Andrej Rypo Date: Thu, 11 Jan 2018 22:01:20 +0100 Subject: [PATCH] improved example and docs wording --- README.md | 6 +++--- examples/factories/UserSelectooFactory.php | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c9f5c75..81dcda1 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ The Aim of Slectoo is to be reusable and flexible. - on-demand (lazy) loading of options using a callback - options can be loaded asynchronously using AJAX - options are only loaded when really needed -- can be skinned with other UI libraries or custom scripts (see below) +- can be skinned with UI libraries or custom scripts (see below) - dependent / cascading inputs ## Notable differences compared to Nette SelectBox & MultiSelectBox -- lazy (callback) options loading +- lazy options loading using a callback - disabling a Selectoo input does not modify/reset its value, so it can be re-enabled without the loss of the information @@ -69,7 +69,7 @@ For best reusability I strongly encourage using factories for inputs with more l typically these involve fetching data from storage or external resources along with JS/UI configuration, handling events and value validation. -See examples: +See simple examples: - [general selectoo factory](examples/factories/Select2SelectooFactory.php) - [example user select factory](examples/factories/UserSelectooFactory.php) - [example AJAX API loaded input](examples/ajax/UserAjaxSelectooFactory.php) diff --git a/examples/factories/UserSelectooFactory.php b/examples/factories/UserSelectooFactory.php index 4bfab7b..fbb55ef 100644 --- a/examples/factories/UserSelectooFactory.php +++ b/examples/factories/UserSelectooFactory.php @@ -14,10 +14,11 @@ */ class Dkj_UserSelectooFactory { + /** @var Dkj_UserRepository */ private $userRepository; - public function __construct($userRepository) + public function __construct(Dkj_UserRepository $userRepository) { $this->userRepository = $userRepository; } @@ -26,7 +27,7 @@ public function __construct($userRepository) public function create($label = null) { $input = new Selectoo($label ?? 'User', function() { - return $this->userRepository->fetchAllUsers(); // returns pairs [ id => name ] + return $this->userRepository->fetchUsers(); // returns pairs [ id => name ] }, false); $engine = new Select2Engine();