commit 1b8d1ab

default  ·  2024-07-11 07:48:50 +0000 UTC
parent 5a42184
Add the 'required' HTML attr to one-option polls (radio buttons).
1 files changed,  +14, -4
M html.c
M html.c
+14, -4
 1@@ -1804,12 +1804,22 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 2                 if (name) {
 3                     char *ti = (char *)xs_number_str(xs_dict_get(replies, "totalItems"));
 4 
 5-                    xs_html_add(form,
 6-                        xs_html_sctag("input",
 7-                            xs_html_attr("type", !xs_is_null(oo) ? "radio" : "checkbox"),
 8+                    xs_html *btn = xs_html_sctag("input",
 9                             xs_html_attr("id", name),
10                             xs_html_attr("value", name),
11-                            xs_html_attr("name", "question")),
12+                            xs_html_attr("name", "question"));
13+
14+                    if (!xs_is_null(oo)) {
15+                        xs_html_add(btn,
16+                            xs_html_attr("type", "radio"),
17+                            xs_html_attr("required", "required"));
18+                    }
19+                    else
20+                        xs_html_add(btn,
21+                            xs_html_attr("type", "checkbox"));
22+
23+                    xs_html_add(form,
24+                        btn,
25                         xs_html_text(" "),
26                         xs_html_tag("span",
27                             xs_html_attr("title", ti),