]> saetta.ns0.it Git - libzakcgi/commitdiff
Loading of filters and validators from xml.
authorAndrea Zagli <azagli@libero.it>
Sat, 7 Nov 2015 21:11:18 +0000 (22:11 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 7 Nov 2015 21:11:18 +0000 (22:11 +0100)
tests/form_xml.c
tests/form_xml.xml

index 517c9039f05205eb75c75210b43df78001c48c3c..970b5da1590774b7d6dcd52b6c2bf850d25aa7d3 100644 (file)
@@ -38,6 +38,9 @@ main (int argc, char *argv[])
 
        GString *str;
 
+       GValue *val;
+       gchar *filename;
+
        ZakCgiForm *form;
        ZakCgiFormElement *element;
 
@@ -57,13 +60,15 @@ main (int argc, char *argv[])
                                                "<body>\n"
                                                "<div class=\"container\">\n");
 
+       val = zak_cgi_main_get_parameter (zakcgimain, "filename");
+       filename = (gchar *)g_value_get_string (val);
+
        form = zak_cgi_form_new (zakcgimain,
                                                         "method", "post",
-                                                        "action", "form",
+                                                        "action", g_strdup_printf ("form_xml?filename=%s", filename),
                                                         NULL);
 
-    GValue *val = zak_cgi_main_get_parameter (zakcgimain, "filename");
-       if (zak_form_form_load_from_file (ZAK_FORM_FORM (form), g_value_get_string (val)))
+       if (zak_form_form_load_from_file (ZAK_FORM_FORM (form), filename))
                {
                        if (zak_cgi_main_is_post (zakcgimain))
                                {
index 34ef91f631abb503ac2f49a1ad9bc8179aa2f322..5146bd1ade00ff8357d9b229a70063e0a9fe770c 100644 (file)
@@ -4,6 +4,8 @@
   <element type="zak_cgi_form_element_text">
        <id>first</id>
        <label>The Label for first</label>
+       <filter type="zak_form_element_filter_trim"></filter>
+       <validator type="zak_form_element_validator_regex">^blahblahblah$</validator>
   </element>
 
   <element type="zak_cgi_form_element_check">