aboutsummaryrefslogtreecommitdiff
path: root/form_category.c
diff options
context:
space:
mode:
Diffstat (limited to 'form_category.c')
-rw-r--r--form_category.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/form_category.c b/form_category.c
new file mode 100644
index 0000000..34d442b
--- /dev/null
+++ b/form_category.c
@@ -0,0 +1,40 @@
+#define _POSIX_C_SOURCE 200809L
+
+#include "form.h"
+#include <libweb/html.h>
+#include <stdio.h>
+
+int form_category(struct html_node *const n)
+{
+ struct html_node *div, *form, *lname, *iname, *submit;
+
+ if (!(div = html_node_add_child(n, "div"))
+ || !(form = html_node_add_child(div, "form"))
+ || !(lname = html_node_add_child(form, "label"))
+ || !(iname = html_node_add_child(form, "input"))
+ || !(submit = html_node_add_child(form, "input")))
+ {
+ fprintf(stderr, "%s: html_node_add_child failed\n", __func__);
+ return -1;
+ }
+ else if (html_node_add_attr(form, "action", "/create/")
+ || html_node_add_attr(form, "form", "categoryform")
+ || html_node_add_attr(form, "method", "post")
+ || html_node_add_attr(lname, "for", "name")
+ || html_node_add_attr(iname, "type", "text")
+ || html_node_add_attr(iname, "id", "name")
+ || html_node_add_attr(iname, "name", "name")
+ || html_node_add_attr(submit, "type", "submit")
+ || html_node_add_attr(submit, "value", "Create"))
+ {
+ fprintf(stderr, "%s: html_node_add_attr failed\n", __func__);
+ return -1;
+ }
+ else if (html_node_set_value(lname, "Create category"))
+ {
+ fprintf(stderr, "%s: html_node_set_value failed\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}