Changing the value in a row programatically when using XLForm

292 Views Asked by At

I've been trying to change the value of an XLForm row programatically after I load some data from an API call. The form is on screen so needs to be reloaded as its visible.

I've tried setting a new options object. Forcing a call to say that the values have changes. Reloading the table view and nothing is working. I've also tried to change the value like this.

[(XLFormRowDescriptor *)self.formRows[@"year"] setValue:self.trade.year];

Can someone please let me know how to change one?

1

There are 1 best solutions below

0
On
XLFormViewController *formVC = ...
XLFormDescriptor *form = formVC.form;

// get your row descriptor from the form descriptor
XLFormRowDescriptor *row = [form formRowWithTag:@"tag"];
OR
XLFormRowDescriptor *row = [form formRowAtIndex:indexPath];

// now update your row value
row.value = @"New Value";

// finally, reload the row via the XLFormViewControllerDelegate method in the XLFormViewController
[formVC reloadFormRow:row];  // this will probably be done inside of the XLFormViewController class