{"action":"created","issue":{"url":"https://api.github.com/repos/nicklockwood/FXForms/issues/431","labels_url":"https://api.github.com/repos/nicklockwood/FXForms/issues/431/labels{/name}","comments_url":"https://api.github.com/repos/nicklockwood/FXForms/issues/431/comments","events_url":"https://api.github.com/repos/nicklockwood/FXForms/issues/431/events","html_url":"https://github.com/nicklockwood/FXForms/issues/431","id":119738870,"number":431,"title":"Update Field Value and refresh display after selecting from options","user":{"login":"jatindhawan","id":2730660,"avatar_url":"https://avatars.githubusercontent.com/u/2730660?v=3","gravatar_id":"","url":"https://api.github.com/users/jatindhawan","html_url":"https://github.com/jatindhawan","followers_url":"https://api.github.com/users/jatindhawan/followers","following_url":"https://api.github.com/users/jatindhawan/following{/other_user}","gists_url":"https://api.github.com/users/jatindhawan/gists{/gist_id}","starred_url":"https://api.github.com/users/jatindhawan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jatindhawan/subscriptions","organizations_url":"https://api.github.com/users/jatindhawan/orgs","repos_url":"https://api.github.com/users/jatindhawan/repos","events_url":"https://api.github.com/users/jatindhawan/events{/privacy}","received_events_url":"https://api.github.com/users/jatindhawan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-01T15:20:25Z","updated_at":"2015-12-03T02:20:40Z","closed_at":null,"body":"I have a CreateFormViewController, init looks like below:\r\n\r\n    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil\r\n    {\r\n        if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))\r\n        {\r\n            //set up form\r\n            self.myForm = [[DynamicForm alloc] init];\r\n            self.formController.form = self.myForm;\r\n            self.formController.tableView = self.tableView;\r\n        }\r\n        return self;\r\n    }\r\n\r\nI am first using a json file to define all fields. Consider this example of a field which has following properties:\r\n\r\n    @{FXFormFieldKey: @\"Reason\" , FXFormFieldTitle: [transLib valueForKey:@\"Reason\"] , FXFormFieldOptions: @[ @\"test\"], FXFormFieldHeader: @\"Appointment Details\",FXFormFieldType: @\"Text\"}\r\n\r\nNow in the Dynamicform I have assigned a customised FXFormFieldViewController to Reason field:\r\n\r\n    - (NSDictionary *)ReasonField\r\n    {\r\n        return @{FXFormFieldViewController: @\"FieldSelectorViewController\"};\r\n    }\r\n\r\nNow in FieldSelectorViewController, I get data from server and display all options and then upon selection of a field I tried a few things to update the field value in the form from previous controller:\r\n1. I have tried sending a NSNotification with data and then simply calling the below:\r\n\r\n    [self.myForm setValue:displayValue forKey:keyName];\r\n    self.formController.form = self.myForm;\r\n    [self.tableView reloadData];\r\n2. FieldSelectorViewController also has a field property, I have tried updating that field's value\r\n3. I have also tried the below on the callback after selection:\r\n    [self.formController enumerateFieldsWithBlock:^(FXFormField *field, NSIndexPath *indexPath) {\r\n        if ([field.key isEqualToString:keyName]) {\r\n            field.value = displayValue;\r\n            [self.tableView reloadData];\r\n        }\r\n    }]; \r\n\r\nbut it is not working"},"comment":{"url":"https://api.github.com/repos/nicklockwood/FXForms/issues/comments/161496123","html_url":"https://github.com/nicklockwood/FXForms/issues/431#issuecomment-161496123","issue_url":"https://api.github.com/repos/nicklockwood/FXForms/issues/431","id":161496123,"user":{"login":"nicklockwood","id":546885,"avatar_url":"https://avatars.githubusercontent.com/u/546885?v=3","gravatar_id":"","url":"https://api.github.com/users/nicklockwood","html_url":"https://github.com/nicklockwood","followers_url":"https://api.github.com/users/nicklockwood/followers","following_url":"https://api.github.com/users/nicklockwood/following{/other_user}","gists_url":"https://api.github.com/users/nicklockwood/gists{/gist_id}","starred_url":"https://api.github.com/users/nicklockwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicklockwood/subscriptions","organizations_url":"https://api.github.com/users/nicklockwood/orgs","repos_url":"https://api.github.com/users/nicklockwood/repos","events_url":"https://api.github.com/users/nicklockwood/events{/privacy}","received_events_url":"https://api.github.com/users/nicklockwood/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T02:20:40Z","updated_at":"2015-12-03T02:20:40Z","body":"The FieldSelectorViewController should have a field property of type FXFormField, like this:\r\n\r\n    @property (nonatomic, strong) FXFormField *field;\r\n\r\nThis will be automatically populated by the parent form (your DynamicForm class) when the Reason field is selected.\r\n\r\nTo update the value from within the FieldSelectorViewController, just set the value of the field, like this:\r\n\r\n    self.field.value = @\"New Value\";\r\n\r\nAnd that should then update the value of the Reason property in the DynamicForm. To refresh the display of the field in the FieldSelectorViewController you may also need to call\r\n\r\n    [self.tableView reloadData];\r\n"}}