diff --git a/lib/src/form/src/controller.dart b/lib/src/form/src/controller.dart index a40f82d..faa683f 100644 --- a/lib/src/form/src/controller.dart +++ b/lib/src/form/src/controller.dart @@ -73,11 +73,6 @@ class AstromicFormController extends FormController { for (MapEntry fieldEntry in groupStructure.fields.entries) { String fieldID = '${groupStructure.id}-$i-${fieldEntry.key}'; controller(fieldID); - // if (fieldEntry.value) { - // // Is a value field - // } else { - // // Is a text field - // } } } } @@ -121,20 +116,27 @@ class AstromicFormController extends FormController { } } + print('Got the structure: $groupStructure'); + // Get the current fields with this ID Map firstSetOfFieldsWithID = Map.fromEntries( controllers.entries.where((MapEntry c) => RegExp(formGroupID + r'-#[\d+]-' + groupStructure!.fields.entries.first.key).hasMatch(c.key)).nonNulls.toList(), ); + + print('First set of fields: $firstSetOfFieldsWithID'); // get the fields IDs List fieldsIDs = groupStructure!.fields.entries.where((MapEntry e) => !e.value).nonNulls.map((MapEntry ee) => ee.key).toList(); + print('fieldIDs: $fieldsIDs'); // get the values IDs List valuesIDs = groupStructure.fields.entries.where((MapEntry e) => e.value).nonNulls.map((MapEntry ee) => ee.key).toList(); + print('valueIDs: $valuesIDs'); // get the subGroups List subValues = []; if (groupStructure.subGroups != null && groupStructure.subGroups!.isNotEmpty) { subValues = groupStructure.subGroups!.map((FormGroupStructure s) => getFormGroupValue(s.id, isSubGroup: true)).nonNulls.toList(); } + print('subValues: $subValues'); List instances = []; for (int i = 0; i < firstSetOfFieldsWithID.length; i++) { @@ -192,7 +194,6 @@ class AstromicFormController extends FormController { // } // } - void getFormGroupValues(FormGroupStructure group) {} // Map> getFormGroup(String groupID){}