From 94aea1520fcdcdc28368043a91bb56255bd0c056 Mon Sep 17 00:00:00 2001 From: Tobias Westergaard Kjeldsen Date: Fri, 29 May 2015 15:20:55 +0200 Subject: [PATCH 1/2] Use lastObject instead of objectAtIndex:0 in multivalued section as template for new row. This is needed when you add values programmatically to a multivalued section. With objectAtIndex:0 the new row will contain the value of the first added row; which in normal circumstances works because you use a dummy row with a placeholder text. When adding rows programmatically based on predefined data this does not make sense. --- XLForm/XL/Controllers/XLFormViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XLForm/XL/Controllers/XLFormViewController.m b/XLForm/XL/Controllers/XLFormViewController.m index a233abe6..b01c17ce 100755 --- a/XLForm/XL/Controllers/XLFormViewController.m +++ b/XLForm/XL/Controllers/XLFormViewController.m @@ -411,7 +411,7 @@ -(XLFormRowDescriptor *)formRowFormMultivaluedFormSection:(XLFormSectionDescript if (formSection.multivaluedRowTemplate){ return [formSection.multivaluedRowTemplate copy]; } - XLFormRowDescriptor * formRowDescriptor = [[formSection.formRows objectAtIndex:0] copy]; + XLFormRowDescriptor * formRowDescriptor = [[formSection.formRows lastObject] copy]; formRowDescriptor.tag = nil; return formRowDescriptor; } From 6ef57913b2c2f912b2839d4d13928266073c5a12 Mon Sep 17 00:00:00 2001 From: Tobias Westergaard Kjeldsen Date: Tue, 22 Dec 2015 11:06:34 +0100 Subject: [PATCH 2/2] Add locale-specific decimal handling with XLFormRowDescriptorTypeDecimal --- XLForm/XL/Cell/XLFormTextFieldCell.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/XLForm/XL/Cell/XLFormTextFieldCell.m b/XLForm/XL/Cell/XLFormTextFieldCell.m index f8531229..237bd0f4 100644 --- a/XLForm/XL/Cell/XLFormTextFieldCell.m +++ b/XLForm/XL/Cell/XLFormTextFieldCell.m @@ -261,7 +261,10 @@ - (void)textFieldDidEndEditing:(UITextField *)textField - (void)textFieldDidChange:(UITextField *)textField{ if([self.textField.text length] > 0) { if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeNumber] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDecimal]){ - self.rowDescriptor.value = @([self.textField.text doubleValue]); + NSNumberFormatter * myNumFormatter = [[NSNumberFormatter alloc] init]; + [myNumFormatter setLocale:[NSLocale currentLocale]]; + [myNumFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; + self.rowDescriptor.value = [myNumFormatter numberFromString:self.textField.text]; } else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInteger]){ self.rowDescriptor.value = @([self.textField.text integerValue]); } else {