]> saetta.ns0.it Git - zakform/cgi/commitdiff
Added function FormElement::render_error_helpbox.
authorAndrea Zagli <azagli@libero.it>
Sat, 2 Jan 2021 07:51:47 +0000 (08:51 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 2 Jan 2021 07:51:47 +0000 (08:51 +0100)
src/formelement.c
src/formelement.h

index 5618b62dd4b7328cdca5c5a9f01b236bc54e64ba..7ec4b2b1886eacec6715149e7da6af2bfff1af9d 100644 (file)
@@ -240,11 +240,8 @@ gchar
                        for (i = 0; i < messages->len; i++)
                                {
                                        g_string_append_printf (str,
-                                                               "\n<span id=\"helpBox_%s_%d\" class=\"%s\">%s</span>",
-                                                               priv->id,
-                                                               i + 1,
-                                                               g_strcmp0 (priv->bootstrap_version, "4") == 0 ? "invalid-feedback" : "help-block",
-                                                               (gchar *)g_ptr_array_index (messages, i));
+                                                               "\n%s",
+                                                               zak_form_cgi_form_element_render_error_helpbox (element, i + 1, (const gchar *)g_ptr_array_index (messages, i)));
                                }
                }
 
@@ -301,6 +298,31 @@ gchar
        return ret;
 }
 
+/**
+ * zak_form_cgi_form_element_render_error_helpbox:
+ * @element:
+ * @idx:
+ * @message:
+ *
+ */
+gchar
+*zak_form_cgi_form_element_render_error_helpbox (ZakFormCgiFormElement *element, guint idx, const gchar *message)
+{
+       gchar *ret;
+
+       ZakFormCgiFormElementPrivate *priv;
+
+       priv = zak_form_cgi_form_element_get_instance_private (element);
+
+       ret = g_strdup_printf ("<span id=\"helpBox_%s_%d\" class=\"%s\">%s</span>",
+                              priv->id,
+                              idx,
+                              g_strcmp0 (priv->bootstrap_version, "4") == 0 ? "invalid-feedback" : "help-block",
+                              message);
+
+       return ret;
+}
+
 gchar
 *zak_form_cgi_form_element_get_attr (ZakFormCgiFormElement *element, const gchar *attr)
 {
index 03815b9ab463b6dd85d8bae4cb6c368977fde372..4a469a9070bdb67cca2d269b32532106f41214a5 100644 (file)
@@ -54,6 +54,7 @@ void zak_form_cgi_form_element_bind (ZakFormCgiFormElement *element, GValue *val
 
 gchar *zak_form_cgi_form_element_render (ZakFormCgiFormElement *element);
 gchar *zak_form_cgi_form_element_render_label (ZakFormCgiFormElement *element);
+gchar *zak_form_cgi_form_element_render_error_helpbox (ZakFormCgiFormElement *element, guint idx, const gchar *message);
 
 gchar *zak_form_cgi_form_element_get_attr (ZakFormCgiFormElement *element, const gchar *attr);
 void zak_form_cgi_form_element_set_attr (ZakFormCgiFormElement *element, const gchar *attr, const gchar *value);