add a checkbox example

This commit is contained in:
lovasoa
2024-12-25 12:21:33 +01:00
parent 155e820ffc
commit 9135861df2
3 changed files with 10 additions and 6 deletions
+7 -5
View File
@@ -1,6 +1,8 @@
select 'form' as component;
select 'text' as type, 'Username' as name, username as value
from users where id = $id;
update users
set username = :Username,
is_admin = :Administrator is not null
where :Username is not null and id = $id;
update users set username = :Username
where id = $id and :Username is not null;
select 'form' as component;
select 'text' as type, 'Username' as name, username as value from users where id = $id;
select 'checkbox' as type, 'Has administrator privileges' as label, 'Administrator' as name, is_admin as checked from users where id = $id;
@@ -15,6 +15,7 @@ SELECT 'list' AS component,
'Users' AS title;
SELECT username AS title,
username || ' is a user on this website.' as description,
case when is_admin then 'red' end as color,
'user' as icon,
'user.sql?id=' || id as link
FROM users;
@@ -1,4 +1,5 @@
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL
username TEXT NOT NULL,
is_admin BOOLEAN NOT NULL DEFAULT FALSE
);