From: Andrea Zagli Date: Sat, 6 May 2017 10:05:52 +0000 (+0200) Subject: Added private function ZakFormCgiFormElement::get_ht_label_attrs. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=170af152ccb75e0017ebedf736d4140e37cbc9dd;p=zakform%2Fcgi Added private function ZakFormCgiFormElement::get_ht_label_attrs. --- diff --git a/src/formelement.c b/src/formelement.c index ff07002..f17829c 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -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 ("
\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 ("
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) { diff --git a/src/formelement.h b/src/formelement.h index a8da1df..23c3de8 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -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); diff --git a/src/formelementradio.c b/src/formelementradio.c index ac79493..11a1dbc 100644 --- a/src/formelementradio.c +++ b/src/formelementradio.c @@ -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 ("
\n"); + } + else + { + ret = g_string_new (""); + } element_value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));