]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Using <name>::<name> ZakFormForm::get_element_by_id returns an array subelement.
authorAndrea Zagli <azagli@libero.it>
Mon, 13 Apr 2020 15:03:12 +0000 (17:03 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 13 Apr 2020 15:03:12 +0000 (17:03 +0200)
src/form.c

index 7358f1cb8681bd6fb47cc16b8aa89526977d3a8f..5478b2af80281c610145df4de5d45759daa03afe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,7 @@
 #include "form.h"
 #include "formelementfilter.h"
 #include "formelementvalidator.h"
+#include "formelementarray.h"
 
 
 typedef ZakFormValidator *(* FormValidatorConstructorFunc) (void);
@@ -397,6 +398,22 @@ ZakFormElement
                {
                        ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (priv->ar_elements, i);
 
+                       if (ZAK_FORM_IS_ELEMENT_ARRAY (element)
+                           && g_strstr_len (id, -1, "::") != NULL)
+                               {
+                                       gchar **splitted;
+
+                                       splitted = g_strsplit (id, "::", -1);
+
+                                       if (g_strcmp0 (zak_form_element_get_name (element), splitted[0]) == 0)
+                                               {
+                                                       ret = zak_form_element_array_get_element_by_id (element, splitted[1]);
+                                                       break;
+                                               }
+
+                                       g_strfreev (splitted);
+                               }
+
                        if (g_strcmp0 (zak_form_element_get_name (element), id) == 0)
                                {
                                        ret = element;