]> saetta.ns0.it Git - zakform/cgi/commitdiff
B4: class form-check for radio and check must be repeated for each element.
authorAndrea Zagli <azagli@libero.it>
Sat, 15 Aug 2020 06:25:48 +0000 (08:25 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 15 Aug 2020 06:25:48 +0000 (08:25 +0200)
src/formelement.c
src/formelementcheck.c
src/formelementradio.c

index 9934afb2383e4b77104675c4e4232a8aa35d97d2..1d6793a1c87d684d9b4d2e218967de202acff6f2 100644 (file)
@@ -24,8 +24,6 @@
 #include <libzakcgi/libzakcgi.h>
 
 #include "formelement.h"
-#include "formelementcheck.h"
-#include "formelementradio.h"
 
 enum
 {
@@ -248,21 +246,6 @@ gchar
                                        g_hash_table_insert (priv->ht_attrs, (gpointer)"readonly", (gpointer)"readonly");
                                }
 
-                       if ((ZAK_FORM_CGI_IS_FORM_ELEMENT_CHECK (element)
-                            || ZAK_FORM_CGI_IS_FORM_ELEMENT_RADIO (element))
-                           && g_strcmp0 (zak_form_cgi_form_element_get_bootstrap_version (element), "4") == 0)
-                               {
-                                       g_string_append (str, "<div class=\"form-check");
-                                       if ((ZAK_FORM_CGI_IS_FORM_ELEMENT_CHECK (element)
-                                            && zak_form_cgi_form_element_check_get_in_line (ZAK_FORM_CGI_FORM_ELEMENT_CHECK (element)))
-                                           || (ZAK_FORM_CGI_IS_FORM_ELEMENT_RADIO (element)
-                                               && zak_form_cgi_form_element_radio_get_in_line (ZAK_FORM_CGI_FORM_ELEMENT_RADIO (element))))
-                                               {
-                                                       g_string_append (str, " form-check-inline");
-                                               }
-                                       g_string_append (str, "\">\n");
-                               }
-
                        g_string_append (str, ZAK_FORM_CGI_FORM_ELEMENT_GET_CLASS (element)->render (element));
                }
 
@@ -279,13 +262,6 @@ gchar
                                }
                }
 
-       if ((ZAK_FORM_CGI_IS_FORM_ELEMENT_CHECK (element)
-            || ZAK_FORM_CGI_IS_FORM_ELEMENT_RADIO (element))
-           && g_strcmp0 (zak_form_cgi_form_element_get_bootstrap_version (element), "4") == 0)
-               {
-                       g_string_append (str, "</div>\n");
-               }
-
        g_string_append (str, "\n</div>\n");
 
        ret = g_strdup (str->str);
index beb3caef32e4141cf858ddfeb1d9bc05bca44c38..944f829d193ee44dcba9def7e467824fd53acbc6 100644 (file)
@@ -279,7 +279,8 @@ static gchar
                {
                        g_hash_table_insert (ht_attrs, "class", g_strdup_printf ("%s form-check-input", g_hash_table_lookup (ht_attrs, "class")));
 
-                       g_string_append_printf (str, "\n%s<label class=\"form-check-label\" for=\"%s\">%s</label>",
+                       g_string_append_printf (str, "\n<div class=\"form-check%s\">\n%s<label class=\"form-check-label\" for=\"%s\">%s</label>\n</div>",
+                                               priv->in_line ? " form-check-inline" : "",
                                                zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs),
                                                zak_form_cgi_form_element_get_id (element),
                                                zak_form_cgi_form_element_check_get_text (ZAK_FORM_CGI_FORM_ELEMENT_CHECK (element)));
index c1704c07fac8c06c5c5dc22c6b91160555f33eb5..fa359ddec3d2cba039dd1c610c3dba7f85e3785a 100644 (file)
@@ -229,7 +229,6 @@ gchar
        guint i;
 
        GHashTable *ht_attrs;
-       GHashTable *ht_label_attrs;
        GHashTable *ht_attrs_option;
 
        gchar *attr_class;
@@ -243,16 +242,8 @@ gchar
        klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_RADIO_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_RADIO (element)));
 
        ht_attrs = klass->get_ht_attrs (element);
-       ht_label_attrs = klass->get_ht_label_attrs (element);
 
-       if (ht_label_attrs != NULL)
-               {
-                       ret = g_string_new ("<br/>\n");
-               }
-       else
-               {
-                       ret = g_string_new ("");
-               }
+       ret = g_string_new ("");
 
        element_value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
 
@@ -293,7 +284,8 @@ gchar
                {
                        /* g_hash_table_insert (ht_attrs_option, "class", g_strdup_printf ("%s form-check-input", g_hash_table_lookup (ht_attrs_option, "class"))); */
 
-                       g_string_append_printf (ret, "\n%s<label class=\"form-check-label\" for=\"%s_%d\">&nbsp;%s</label>",
+                       g_string_append_printf (ret, "\n<div class=\"form-check%s\">\n%s<label class=\"form-check-label\" for=\"%s_%d\">&nbsp;%s</label>\n</div>",
+                                               priv->in_line ? " form-check-inline" : "",
                                                zak_cgi_tag_tag_ht ("input",
                                                                    g_strdup_printf ("%s_%d",
                                                                                     zak_form_cgi_form_element_get_id (element),
@@ -318,11 +310,25 @@ static gchar
        gchar *ret_value;
        GString *ret;
 
+       GHashTable *ht_label_attrs;
+
        guint i;
 
+       ZakFormCgiFormElementClass *klass;
+
        ZakFormCgiFormElementRadioPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_RADIO_GET_PRIVATE (element);
 
-       ret = g_string_new ("");
+       klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_RADIO_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_RADIO (element)));
+       ht_label_attrs = klass->get_ht_label_attrs (element);
+
+       if (ht_label_attrs != NULL)
+               {
+                       ret = g_string_new ("<br/>\n");
+               }
+       else
+               {
+                       ret = g_string_new ("");
+               }
 
        for (i = 0; i < priv->ar_options->len; i++)
                {