]> saetta.ns0.it Git - libzakcgi/commitdiff
Setted name and long name of ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Sun, 7 Feb 2016 12:55:20 +0000 (13:55 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 7 Feb 2016 12:55:20 +0000 (13:55 +0100)
src/formelement.c

index 4cb664b5c45297a70f61b301900110c8f84b2147..2f0e21d4a618caeedea792c03948e811a7e16cc4 100644 (file)
@@ -122,8 +122,10 @@ zak_cgi_form_element_set_label (ZakCgiFormElement *element, const gchar *label,
        priv->ht_label_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
 
        g_hash_table_replace (priv->ht_label_attrs, "zak-cgi-content", g_strdup (label));
-       g_hash_table_replace (priv->ht_label_attrs, "for", g_hash_table_lookup (priv->ht_attrs, "name"));
+       g_hash_table_replace (priv->ht_label_attrs, "for", priv->id != NULL  ? g_strdup (priv->id) : g_strdup (""));
        g_hash_table_replace (priv->ht_label_attrs, "class", "control-label");
+
+       zak_form_element_set_long_name (ZAK_FORM_ELEMENT (element), label);
 }
 
 /**
@@ -156,6 +158,11 @@ gchar
                {
                        gchar *lbl_id;
 
+                       if (g_strcmp0 (g_hash_table_lookup (priv->ht_label_attrs, "for"), "") == 0)
+                               {
+                                       g_hash_table_replace (priv->ht_label_attrs, "for", g_strdup (priv->id));
+                               }
+
                        lbl_id = g_strdup_printf ("lbl_%s", priv->id);
                        g_string_append (str, zak_cgi_tag_tag_ht ("label", lbl_id, priv->ht_label_attrs));
                        g_free (lbl_id);
@@ -224,6 +231,7 @@ zak_cgi_form_element_construct (ZakCgiFormElement *element,
                {
                        g_hash_table_insert (priv->ht_attrs, "name", g_strdup (id));
                }
+       zak_form_element_set_name (ZAK_FORM_ELEMENT (element), g_hash_table_lookup (priv->ht_attrs, "name"));
 
        return;
 }