diff options
| author | patrick-scho | 2025-04-08 20:54:10 +0200 |
|---|---|---|
| committer | patrick-scho | 2025-04-08 20:54:10 +0200 |
| commit | d8f54dd8ac187349c1194871a55d4675f28e5a43 (patch) | |
| tree | 22c94f829f3d202bef8d016bf37717a1af74bdd7 /src | |
| parent | 355355f8305852a609d3960fb9e9b07177cf8f1f (diff) | |
| download | chirp-d8f54dd8ac187349c1194871a55d4675f28e5a43.tar.gz chirp-d8f54dd8ac187349c1194871a55d4675f28e5a43.zip | |
add ability to specify tag type to html_form
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig index 8cabda6..164606f 100644 --- a/src/main.zig +++ b/src/main.zig @@ -509,10 +509,16 @@ fn html_form(res: *http.Response, action: []const u8, inputs: anytype) !void { inline for (inputs) |input| { switch (@typeInfo(@TypeOf(input))) { - .Struct => { - try res.write("<input ", .{}); - try res.write(input[0], input[1]); - try res.write(" />", .{}); + .Struct => |s| { + if (s.fields.len == 3) { + try res.write("<{s} ", .{input[0]}); + try res.write(input[1], input[2]); + try res.write("></{s}>", .{input[0]}); + } else { + try res.write("<input ", .{}); + try res.write(input[0], input[1]); + try res.write(" />", .{}); + } }, else => { try res.write("<input ", .{}); @@ -1265,7 +1271,7 @@ const GET = struct { }); try self.res.write("<br />Description: ", .{}); try html_form(self.res, "/set_description", .{ - .{ "type=\"text\" name=\"description\" placeholder=\"{s}\"", .{login.user.description.constSlice()} }, + .{ "textarea", "type=\"text\" name=\"description\" placeholder=\"{s}\"", .{login.user.description.constSlice()} }, "type=\"submit\" value=\"Change\"", }); try self.res.write("<br />Password: ", .{}); |
