Skip to content

Commit 6d76983

Browse files
committed
docs (reordered sections and typo fix)
1 parent d29249b commit 6d76983

File tree

1 file changed

+47
-51
lines changed

1 file changed

+47
-51
lines changed

readme.md

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
SelectBox & MultiSelectBox hybrid input with lazy & asynchronous options loading capabilities to be used with Select2, Selectize, Chosen and similar UI libraries.
77

8-
The aim of Slectoo is to provide a flexible tool for creating reusable select inputs.
8+
The aim of Selectoo is to provide a flexible tool for creating reusable select inputs.
99

1010

1111
## Features
@@ -20,42 +20,6 @@ The aim of Slectoo is to provide a flexible tool for creating reusable select in
2020
- dependent / cascading inputs
2121

2222

23-
## Notable differences compared to Nette SelectBox & MultiSelectBox
24-
25-
- lazy options loading using a callback
26-
- disabling a Selectoo input does not modify/reset its value, so it can be re-enabled without the loss of the information
27-
28-
29-
## Lazy options loading
30-
31-
Lazy loading is used when the Selectoo instance is given "item callback" callable instead of an array of items.
32-
The callable is supposed to return a list of items.
33-
34-
The item callback also works as a validator for values.
35-
It receives raw value as the first argument (and the input instance as the second).
36-
The callback should return the array of possible values (these are the items) in form
37-
exactly the same as the items set to `SelectBox` or `MultiSelectBox` inputs.
38-
The raw value is then compared to the returned items and filtered.
39-
This approach ensures the validity of the data.
40-
41-
It is important to set this callback in case you work with remote item loading (ajax/api loading of options).
42-
43-
44-
## Supported and intended UI libraries
45-
46-
Selectoo uses "script engines" to generate JavaScript UI scripts along with HTML input element.
47-
Any script engine can be attached to the `Selectoo` instance by calling `$selectoo->setEngine($engine)`.
48-
49-
- [select2/select2](https://github.com/select2/select2)
50-
- use the `Select2Engine` instances
51-
- selectize/selectize.js
52-
- to be implemented
53-
- harvesthq/chosen
54-
- to be implemented
55-
56-
Custom engines can easily be created implementing the `ScriptEngineInterface` interface.
57-
58-
5923
## Usage / Use cases
6024

6125
**Reusable** inputs with specific setup:
@@ -99,13 +63,43 @@ The `Select2Engine` is configured using magic options (or `setOption` method).
9963
The names of the magic methods (or option names) represent the ***Select2* configuration options**.
10064

10165

102-
## Script management
66+
## Lazy options loading & AJAX
10367

104-
The scripts generated by engines can be post-processed and/or collected by a management routine.
105-
This approach can be used to gather and place the scripts at the end of the page and to solve problems
106-
when writing scripts inside the page and loading jQuery at the end of the HTML file.
68+
Lazy loading is used when the Selectoo instance is given "item callback" callable instead of an array of items.
69+
The callable is supposed to return a list of items.
10770

108-
See [script-management example](examples/script-management/Select2SelectooWithCollectorFactory.php) for more information.
71+
The item callback also works as a validator for values.
72+
It receives raw value as the first argument (and the input instance as the second).
73+
The callback should return the array of possible values (these are the items) in form
74+
exactly the same as the items set to `SelectBox` or `MultiSelectBox` inputs.
75+
The raw value is then compared to the returned items and filtered.
76+
This approach ensures the validity of the data.
77+
78+
It is important to set this callback in case you work with remote item loading (ajax/api loading of options).
79+
80+
See the [example ajax presenter](examples/ajax/ExamplePresenter.php),
81+
complete with input factory and user repository examples.
82+
83+
Ajax configuration can be very simple:
84+
```php
85+
(new Select2Engine())
86+
->ajax('{url: "' . $link . '", dataType: "json" }')
87+
;
88+
```
89+
90+
## Supported and intended UI libraries
91+
92+
Selectoo uses "script engines" to generate JavaScript UI scripts along with HTML input element.
93+
Any script engine can be attached to the `Selectoo` instance by calling `$selectoo->setEngine($engine)`.
94+
95+
- [select2/select2](https://github.com/select2/select2)
96+
- use the `Select2Engine` instances
97+
- selectize/selectize.js
98+
- to be implemented
99+
- harvesthq/chosen
100+
- to be implemented
101+
102+
Custom engines can easily be created implementing the `ScriptEngineInterface` interface.
109103

110104

111105
## Factories
@@ -120,17 +114,13 @@ See simple examples:
120114
- [example AJAX API loaded input](examples/ajax/UserAjaxSelectooFactory.php)
121115

122116

123-
## Lazy loading & AJAX
117+
## Script management
124118

125-
See the [example ajax presenter](examples/ajax/ExamplePresenter.php),
126-
complete with input factory and user repository examples.
119+
The scripts generated by engines can be post-processed and/or collected by a management routine.
120+
This approach can be used to gather and place the scripts at the end of the page and to solve problems
121+
when writing scripts inside the page and loading jQuery at the end of the HTML file.
127122

128-
Ajax configuration can be very simple:
129-
```php
130-
(new Select2Engine())
131-
->ajax('{url: "' . $link . '", dataType: "json" }')
132-
;
133-
```
123+
See [script-management example](examples/script-management/Select2SelectooWithCollectorFactory.php) for more information.
134124

135125

136126
## Dependent selections / cascading inputs
@@ -151,6 +141,12 @@ What is needed, in general:
151141
By following these steps, dependent Selectoo inputs can be created and values validated.
152142

153143

144+
## Notable differences compared to Nette SelectBox & MultiSelectBox
145+
146+
- disabling a Selectoo input does not modify/reset its value, so it can be re-enabled without the loss of the information
147+
- disabled input is handled differently - raw value is always loaded even when input (or items) is disabled. The disabled values are filtered when calling `getValue` method.
148+
149+
154150
## Requirements
155151

156152
- PHP 7+

0 commit comments

Comments
 (0)