]> saetta.ns0.it Git - zakform/cgi/commitdiff
Added private function ZakFormCgiFormElement::get_ht_label_attrs.
authorAndrea Zagli <azagli@libero.it>
Sat, 6 May 2017 10:05:52 +0000 (12:05 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 6 May 2017 10:05:52 +0000 (12:05 +0200)
src/formelement.c
src/formelement.h
src/formelementradio.c

index ff070021922812a25ff17f49ff049df64ab5086e..f17829c5d92bdf409a3d908f390dd0b52125c711 100644 (file)
@@ -36,6 +36,7 @@ static void zak_form_cgi_form_element_construct (ZakFormCgiFormElement *element,
                                                  GHashTable *ht_attrs);
 
 static GHashTable *zak_form_cgi_form_element_get_ht_attrs (ZakFormCgiFormElement *element);
+static GHashTable *zak_form_cgi_form_element_get_ht_label_attrs (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_set_property (GObject *object,
                                                     guint property_id,
@@ -86,6 +87,7 @@ zak_form_cgi_form_element_class_init (ZakFormCgiFormElementClass *class)
 
        class->construct = zak_form_cgi_form_element_construct;
        class->get_ht_attrs = zak_form_cgi_form_element_get_ht_attrs;
+       class->get_ht_label_attrs = zak_form_cgi_form_element_get_ht_label_attrs;
 }
 
 static void
@@ -185,9 +187,9 @@ gchar
                        g_string_append (str, " has-error");
                }
 
-       g_string_append (str, "\">\n");
+       str = g_string_new ("<div class=\"form-group\">\n");
 
-       zak_form_cgi_form_element_render_label (element);
+       g_string_append (str, zak_form_cgi_form_element_render_label (element));
 
        if (ZAK_FORM_CGI_IS_FORM_ELEMENT (element) && ZAK_FORM_CGI_FORM_ELEMENT_GET_CLASS (element)->render != NULL)
                {
@@ -255,8 +257,7 @@ gchar
 
        if (priv->ht_label_attrs != NULL)
                {
-
-                       str = g_string_new ("<div class=\"form-group");
+                       str = g_string_new ("");
 
                        if (g_strcmp0 (g_hash_table_lookup (priv->ht_label_attrs, "for"), "") == 0)
                                {
@@ -316,6 +317,16 @@ static GHashTable
        return priv->ht_attrs;
 }
 
+static GHashTable
+*zak_form_cgi_form_element_get_ht_label_attrs (ZakFormCgiFormElement *element)
+{
+       ZakFormCgiFormElementPrivate *priv;
+
+       priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+       return priv->ht_label_attrs;
+}
+
 static gchar
 *zak_form_cgi_form_element_get_value (ZakFormCgiFormElement *element)
 {
index a8da1df06644fbb8f53550418293df306e87a10f..23c3de81a3f665559f7a4d2110a849e265229c27 100644 (file)
@@ -38,6 +38,8 @@ struct _ZakFormCgiFormElementClass
                void (*construct) (ZakFormCgiFormElement *element, const gchar *id, GHashTable *ht_attrs);
                GHashTable *(*get_ht_attrs) (ZakFormCgiFormElement *element);
 
+               GHashTable *(*get_ht_label_attrs) (ZakFormCgiFormElement *element);
+
                void (*xml_parsing) (ZakFormElement *element, xmlNode *xmlnode);
 
                gchar *(*render) (ZakFormCgiFormElement *element);
index ac79493edf61c8a60b1883de170442c27960c314..11a1dbc47ca5b0560d6c16134f19e659bfe44db0 100644 (file)
@@ -230,6 +230,7 @@ static gchar
        gpointer value;
 
        GHashTable *ht_attrs;
+       GHashTable *ht_label_attrs;
        GHashTable *ht_attrs_option;
 
        gchar *element_value;
@@ -240,11 +241,19 @@ static gchar
 
        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_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 ("");
+               }
 
        element_value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));