You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/official-site/sqlpage/migrations/01_documentation.sql
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -247,7 +247,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
247
247
('min', 'The minimum value to accept for an input of type number', 'NUMBER', FALSE, TRUE),
248
248
('max', 'The minimum value to accept for an input of type number', 'NUMBER', FALSE, TRUE),
249
249
('checked', 'Used only for checkboxes and radio buttons. Indicates whether the checkbox should appear as already checked.', 'BOOL', FALSE, TRUE),
250
-
('multiple', 'Used only for select elements. Indicates that multiple elements can be selected simultaneously.', 'BOOL', FALSE, TRUE),
250
+
('multiple', 'Used only for select elements. Indicates that multiple elements can be selected simultaneously. When using multiple, you should add square brackets after the variable name: ''my_variable[]'' as name', 'BOOL', FALSE, TRUE),
251
251
('step', 'The increment of values in an input of type number. Set to 1 to allow only integers.', 'NUMBER', FALSE, TRUE),
252
252
('description', 'A helper text to display near the input field.', 'TEXT', FALSE, TRUE),
253
253
('pattern', 'A regular expression that the value must match. For instance, [0-9]{3} will only accept 3 digits.', 'TEXT', FALSE, TRUE),
You can authorize the user to select multiple options by setting the `multiple` property to `true`.
321
+
This creates a more compact (but arguably less user-friendly) alternative to a series of checkboxes.
322
+
In this case, you should add square brackets to the name of the field.
323
+
The target page will then receive the value as a JSON array of strings, which you can iterate over using
324
+
- the `json_each` function [in SQLite](https://www.sqlite.org/json1.html) and [Postgres](https://www.postgresql.org/docs/9.3/functions-json.html),
325
+
- the [`JSON_TABLE`](https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html) function in MySQL (which you''ll need to wrap in a function, because SQLPage cannot parse the non-standard syntax of this function)
326
+
- the [`OPENJSON`](https://learn.microsoft.com/fr-fr/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver16) function in Microsoft SQL Server.
327
+
328
+
The target page could then look like this:
329
+
330
+
```sql
331
+
insert into best_fruits(id) -- INSERT INTO ... SELECT ... runs the SELECT query and inserts the results into the table
332
+
select CAST(value AS integer) as id -- all values are transmitted by the browser as strings
333
+
from json_each($preferred_fruits); -- json_each returns a table with a "value" column for each element in the JSON array
0 commit comments