[SYNC]
This commit is contained in:
@@ -325,10 +325,10 @@ class AstromicFormController extends FormController {
|
|||||||
|
|
||||||
// Initialize the group instances
|
// Initialize the group instances
|
||||||
_initializeGroupControllers(groupStructure, initialCount);
|
_initializeGroupControllers(groupStructure, initialCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Recursively initialize controllers for the group and its subgroups
|
/// Recursively initialize controllers for the group and its subgroups
|
||||||
void _initializeGroupControllers(FormGroupStructure groupStructure, int initialCount, {String parentPrefix = ''}) {
|
void _initializeGroupControllers(FormGroupStructure groupStructure, int initialCount, {String parentPrefix = ''}) {
|
||||||
// Add main group fields/values
|
// Add main group fields/values
|
||||||
for (int groupIndex = 0; groupIndex < initialCount; groupIndex++) {
|
for (int groupIndex = 0; groupIndex < initialCount; groupIndex++) {
|
||||||
_addGroupControllers(groupStructure, groupIndex, parentPrefix: parentPrefix);
|
_addGroupControllers(groupStructure, groupIndex, parentPrefix: parentPrefix);
|
||||||
@@ -336,21 +336,21 @@ class AstromicFormController extends FormController {
|
|||||||
// Recursively handle subgroups
|
// Recursively handle subgroups
|
||||||
if (groupStructure.subGroups != null && groupStructure.subGroups!.isNotEmpty) {
|
if (groupStructure.subGroups != null && groupStructure.subGroups!.isNotEmpty) {
|
||||||
for (final (FormGroupStructure subGroup, int subgroupInitialCount) in groupStructure.subGroups!) {
|
for (final (FormGroupStructure subGroup, int subgroupInitialCount) in groupStructure.subGroups!) {
|
||||||
final String nestedPrefix = parentPrefix.isEmpty
|
final String subgroupPrefix = parentPrefix.isEmpty
|
||||||
? standeredGroupFormat(groupStructure.id, groupIndex, subGroup.id) // If no parentPrefix, use the group directly
|
? standeredGroupFormat(groupStructure.id, groupIndex, subGroup.id)
|
||||||
: '$parentPrefix->${standeredGroupFormat(groupStructure.id, groupIndex, subGroup.id)}'; // Add to parentPrefix
|
: '$parentPrefix->${standeredGroupFormat(groupStructure.id, groupIndex, subGroup.id)}'; // Add to parentPrefix only once
|
||||||
|
|
||||||
// Initialize subgroup controllers recursively
|
// Initialize subgroup controllers recursively
|
||||||
for (int subIndex = 0; subIndex < subgroupInitialCount; subIndex++) {
|
for (int subIndex = 0; subIndex < subgroupInitialCount; subIndex++) {
|
||||||
_initializeGroupControllers(subGroup, subgroupInitialCount, parentPrefix: nestedPrefix);
|
_initializeGroupControllers(subGroup, subgroupInitialCount, parentPrefix: subgroupPrefix);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Validate subgroups recursively
|
/// Validate subgroups recursively
|
||||||
void _validateSubGroups(FormGroupStructure groupStructure) {
|
void _validateSubGroups(FormGroupStructure groupStructure) {
|
||||||
groupStructure.subGroups?.forEach((subGroupTuple) {
|
groupStructure.subGroups?.forEach((subGroupTuple) {
|
||||||
final subGroup = subGroupTuple.$1;
|
final subGroup = subGroupTuple.$1;
|
||||||
assert(subGroup.fields.isNotEmpty, '${subGroup.id}: Subgroup fields should NOT be empty.');
|
assert(subGroup.fields.isNotEmpty, '${subGroup.id}: Subgroup fields should NOT be empty.');
|
||||||
@@ -360,7 +360,8 @@ class AstromicFormController extends FormController {
|
|||||||
_validateSubGroups(subGroup);
|
_validateSubGroups(subGroup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void initializeFormGroup(FormGroupStructure groupStructure, {int initialCount = 1}) {
|
// void initializeFormGroup(FormGroupStructure groupStructure, {int initialCount = 1}) {
|
||||||
// assert(groupStructure.fields.isNotEmpty, '$groupStructure: Group Fields should NOT be empty.');
|
// assert(groupStructure.fields.isNotEmpty, '$groupStructure: Group Fields should NOT be empty.');
|
||||||
|
|||||||
Reference in New Issue
Block a user