Skip to content

Commit 9135861

Browse files
committed
add a checkbox example
1 parent 155e820 commit 9135861

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
select 'form' as component;
2-
select 'text' as type, 'Username' as name, username as value
3-
from users where id = $id;
1+
update users
2+
set username = :Username,
3+
is_admin = :Administrator is not null
4+
where :Username is not null and id = $id;
45

5-
update users set username = :Username
6-
where id = $id and :Username is not null;
6+
select 'form' as component;
7+
select 'text' as type, 'Username' as name, username as value from users where id = $id;
8+
select 'checkbox' as type, 'Has administrator privileges' as label, 'Administrator' as name, is_admin as checked from users where id = $id;

examples/simple-website-example/index.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SELECT 'list' AS component,
1515
'Users' AS title;
1616
SELECT username AS title,
1717
username || ' is a user on this website.' as description,
18+
case when is_admin then 'red' end as color,
1819
'user' as icon,
1920
'user.sql?id=' || id as link
2021
FROM users;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE TABLE users (
22
id INTEGER PRIMARY KEY AUTOINCREMENT,
3-
username TEXT NOT NULL
3+
username TEXT NOT NULL,
4+
is_admin BOOLEAN NOT NULL DEFAULT FALSE
45
);

0 commit comments

Comments
 (0)