diff --git a/XLForm/XL/Controllers/XLFormOptionsViewController.m b/XLForm/XL/Controllers/XLFormOptionsViewController.m index c8524394..bae6f134 100644 --- a/XLForm/XL/Controllers/XLFormOptionsViewController.m +++ b/XLForm/XL/Controllers/XLFormOptionsViewController.m @@ -29,6 +29,7 @@ #import "XLForm.h" #import "NSObject+XLFormAdditions.h" #import "NSArray+XLFormAdditions.h" +#import "XLFormViewController.h" #define CELL_REUSE_IDENTIFIER @"OptionCell" @@ -157,6 +158,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){ [self.navigationController popViewControllerAnimated:YES]; + XLFormViewController *vc = (XLFormViewController *)self.navigationController.topViewController; + [vc.tableView reloadData]; } } [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; diff --git a/XLForm/XL/Descriptors/XLFormRowDescriptor.m b/XLForm/XL/Descriptors/XLFormRowDescriptor.m index af0a959a..51596eeb 100644 --- a/XLForm/XL/Descriptors/XLFormRowDescriptor.m +++ b/XLForm/XL/Descriptors/XLFormRowDescriptor.m @@ -318,6 +318,7 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS id newValue = [change objectForKey:NSKeyValueChangeNewKey]; id oldValue = [change objectForKey:NSKeyValueChangeOldKey]; if ([keyPath isEqualToString:@"value"]){ + [self.sectionDescriptor.formDescriptor forceEvaluate]; [self.sectionDescriptor.formDescriptor.delegate formRowDescriptorValueHasChanged:object oldValue:oldValue newValue:newValue]; if (self.onChangeBlock) { self.onChangeBlock(oldValue, newValue, self); @@ -363,7 +364,18 @@ -(BOOL)evaluateIsDisabled self.isDirtyDisablePredicateCache = YES; } else { @try { - self.disablePredicateCache = @([_disabled evaluateWithObject:self substitutionVariables:self.sectionDescriptor.formDescriptor.allRowsByTag ?: @{}]); + NSMutableDictionary *d = [self.sectionDescriptor.formDescriptor.allRowsByTag mutableCopy] ?: [[NSMutableDictionary alloc] init]; + for (NSString *k in [d allKeys]) { + XLFormRowDescriptor *r = [d objectForKey:k]; + if (r.value == nil) { + continue; + } else if ([r.value isKindOfClass:[XLFormOptionsObject class]]) { + [d setObject:[(XLFormOptionsObject *)r.value formDisplaytext] forKey:k]; + } else { + [d setObject:r.value forKey:k]; + } + } + self.disablePredicateCache = @([_disabled evaluateWithObject:self substitutionVariables:[d copy]]); } @catch (NSException *exception) { // predicate syntax error. @@ -430,7 +442,18 @@ -(BOOL)evaluateIsHidden self.isDirtyHidePredicateCache = YES; } else { @try { - self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:self.sectionDescriptor.formDescriptor.allRowsByTag ?: @{}]); + NSMutableDictionary *d = [self.sectionDescriptor.formDescriptor.allRowsByTag mutableCopy] ?: [[NSMutableDictionary alloc] init]; + for (NSString *k in [d allKeys]) { + XLFormRowDescriptor *r = [d objectForKey:k]; + if (r.value == nil) { + continue; + } else if ([r.value isKindOfClass:[XLFormOptionsObject class]]) { + [d setObject:[(XLFormOptionsObject *)r.value formDisplaytext] forKey:k]; + } else { + [d setObject:r.value forKey:k]; + } + } + self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:[d copy]]); } @catch (NSException *exception) { // predicate syntax error or for has not finished loading. diff --git a/XLForm/XL/Descriptors/XLFormSectionDescriptor.m b/XLForm/XL/Descriptors/XLFormSectionDescriptor.m index e51e7e52..5921810f 100644 --- a/XLForm/XL/Descriptors/XLFormSectionDescriptor.m +++ b/XLForm/XL/Descriptors/XLFormSectionDescriptor.m @@ -364,7 +364,18 @@ -(BOOL)evaluateIsHidden self.isDirtyHidePredicateCache = YES; } else { @try { - self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:self.formDescriptor.allRowsByTag ?: @{}]); + NSMutableDictionary *d = [self.formDescriptor.allRowsByTag mutableCopy] ?: [[NSMutableDictionary alloc] init]; + for (NSString *k in [d allKeys]) { + XLFormRowDescriptor *r = [d objectForKey:k]; + if (r.value == nil) { + continue; + } else if ([r.value isKindOfClass:[XLFormOptionsObject class]]) { + [d setObject:[(XLFormOptionsObject *)r.value formDisplaytext] forKey:k]; + } else { + [d setObject:r.value forKey:k]; + } + } + self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:[d copy]]); } @catch (NSException *exception) { // predicate syntax error.