1 Commits

Author SHA1 Message Date
Mathias Claassen e9de49db86 formValuesIncludingHidden returns all values of a form including the values of hidden rows 2017-05-18 11:56:26 -03:00
4 changed files with 24 additions and 5 deletions
@@ -52,6 +52,7 @@ typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
-(XLFormBaseCell *)updateFormRow:(XLFormRowDescriptor *)formRow;
-(NSDictionary *)formValues;
-(NSDictionary *)formValuesIncludingHidden;
-(NSDictionary *)httpParameters;
-(XLFormRowDescriptor *)formRowFormMultivaluedFormSection:(XLFormSectionDescriptor *)formSection;
@@ -346,6 +346,11 @@
return [self.form formValues];
}
-(NSDictionary *)formValuesIncludingHidden
{
return [self.form formValuesIncludingHidden];
}
-(NSDictionary *)httpParameters
{
return [self.form httpParameters:self];
+1
View File
@@ -82,6 +82,7 @@ typedef NS_OPTIONS(NSUInteger, XLFormRowNavigationOptions) {
-(nullable NSIndexPath *)indexPathOfFormRow:(nonnull XLFormRowDescriptor *)formRow;
-(nonnull NSDictionary *)formValues;
-(nonnull NSDictionary *)formValuesIncludingHidden;
-(nonnull NSDictionary *)httpParameters:(nonnull XLFormViewController *)formViewController;
-(nonnull NSArray *)localValidationErrors:(nonnull XLFormViewController *)formViewController;
+17 -5
View File
@@ -284,13 +284,25 @@ NSString * const XLValidationStatusErrorKey = @"XLValidationStatusErrorKey";
return nil;
}
-(NSDictionary *)formValuesIncludingHidden
{
return [self formValuesWithHidden:YES];
}
-(NSDictionary *)formValues
{
NSMutableDictionary * result = [NSMutableDictionary dictionary];
for (XLFormSectionDescriptor * section in self.formSections) {
return [self formValuesWithHidden:NO];
}
-(NSDictionary *)formValuesWithHidden:(BOOL)includeHidden
{
NSArray* sections = includeHidden ? self.allSections : self.formSections;
NSMutableDictionary* result = [NSMutableDictionary dictionary];
for (XLFormSectionDescriptor * section in sections) {
NSArray* rows = includeHidden ? section.allRows : section.formRows;
if (section.multivaluedTag.length > 0){
NSMutableArray * multiValuedValuesArray = [NSMutableArray new];
for (XLFormRowDescriptor * row in section.formRows) {
NSMutableArray* multiValuedValuesArray = [NSMutableArray new];
for (XLFormRowDescriptor * row in rows) {
if (row.value){
[multiValuedValuesArray addObject:row.value];
}
@@ -298,7 +310,7 @@ NSString * const XLValidationStatusErrorKey = @"XLValidationStatusErrorKey";
[result setObject:multiValuedValuesArray forKey:section.multivaluedTag];
}
else{
for (XLFormRowDescriptor * row in section.formRows) {
for (XLFormRowDescriptor * row in rows) {
if (row.tag.length > 0){
[result setObject:(row.value ?: [NSNull null]) forKey:row.tag];
}