diff options
-rw-r--r-- | src/html.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -552,7 +552,30 @@ mq_html_input_radio(const gchar *name, const gchar *label, gboolean checked) gchar * mq_html_input_checkbox(const gchar *name, const gchar *label, gboolean checked) { + /* + * Values of "checkbox"-type <input>s that are not checked are not sent + * in queries with form submissions. The "about:preferences" + * query-handling code doesn't handle any preferences that aren't + * submitted in the query, so values need to be submitted for unchecked + * "checkbox"-type <input>s in order for unchecking to have any effect. + * + * This function returns two <input>s: one of type "hidden" with a value + * of "off" and one of type "checkbox". If the "checkbox"-type <input> + * is checked, both <input> values will be submitted in the query, with + * the value of the "checkbox"-type <input> last. Otherwise, only the + * "off" value of the "hidden"-type <input> will be submitted. + * + * The query-parsing code for "about"-scheme resources iterates through + * each "key=value" pair in order, inserting each pair into a + * GHashTable. When keys collide, g_hash_table_insert() replaces the + * previous value with the new value. Thus, the value of the + * "checkbox"-type <input> will override that of the "hidden"-type + * <input> when the former <input> is checked. + */ + return g_strdup_printf("<label for=\"%s\"><span>%s</span>" + "<input type=\"hidden\" name=\"%s\" value=\"off\">" "<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s></label>\n", - name, label, name, name, checked ? " checked=\"checked\"" : ""); + name, label, name, name, name, + checked ? " checked=\"checked\"" : ""); } |