]> saetta.ns0.it Git - libzakcgi/commitdiff
Wrong render of form checkbox (closes #1015).
authorAndrea Zagli <azagli@libero.it>
Sun, 15 May 2016 09:09:52 +0000 (11:09 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 15 May 2016 09:09:52 +0000 (11:09 +0200)
src/formelementcheck.c

index e44ef33544b5208159f41ff0c09132e06f644b57..d3b62fc40cd1a53884bc0a29d357dea8e8c2d254 100644 (file)
@@ -20,6 +20,8 @@
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
+
 #include "commons.h"
 #include "tag.h"
 #include "formelementcheck.h"
@@ -29,8 +31,6 @@ static void zak_cgi_form_element_check_init (ZakCgiFormElementCheck *zak_cgi_for
 
 static gchar *zak_cgi_form_element_check_render (ZakCgiFormElement *element);
 
-static gboolean zak_cgi_form_element_check_is_valid (ZakCgiFormElement *element);
-
 static void zak_cgi_form_element_check_set_property (GObject *object,
                                guint property_id,
                                const GValue *value,
@@ -193,9 +193,10 @@ static gchar
        ht_attrs = klass->get_ht_attrs (element);
 
        value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
-       if (value != NULL)
+       if (value != NULL
+               && zak_utils_string_to_boolean (value))
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)"checked", (gpointer)"checked");
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_cgi_form_element_get_id (element), ht_attrs);