FXForms icon indicating copy to clipboard operation
FXForms copied to clipboard

Populate inline array field

Open stefanocdn opened this issue 10 years ago • 3 comments

Hi, I'm trying to populate FXForm fields with network data, it's working for all fields except for inline fields. Right now I try to assign:

form.inlineField = arrayWithNetworkData;
[self.tableView reloadData];

But it's not working. Any idea how I could achieve that? Thx

stefanocdn avatar Oct 14 '14 20:10 stefanocdn

I'll need a bit more detail. Can you paste in your form class and the json for that field?

nicklockwood avatar Oct 14 '14 20:10 nicklockwood

Sure, the form is a user profile form with properties;

@property (nonatomic, copy) NSString *firstName;
@property (nonatomic, copy) NSString *lastName;
@property (nonatomic, strong) NSDate *dateOfBirth;
@property (nonatomic, strong) NSArray *languages;

Where languagesField is set inline

- (NSDictionary *)languagesField
{
    return @{FXFormFieldInline: @YES};
}

When the viewcontroller, which is a subclass of FXFormViewController, is loaded (to allow the user to edit these properties) I populate the fields like so:

    UserProfileForm *form = (UserProfileForm *)self.formController.form;
    if(self.user.firstName) form.firstName = self.user.firstName;
    if(self.user.lastName) form.lastName = self.user.lastName;
    if(self.user.birthday) form.dateOfBirth = self.user.birthday;
    if(self.user.languages) form.languages = self.user.languages;

Which works for all fields except for languages, even after [self.tableView reloadData].

stefanocdn avatar Oct 14 '14 20:10 stefanocdn

Before calling [self.tableView reloadData], try calling this:

self.formController.form = self.formController.form;

or whatever your viewcontroller is called.

frakman1 avatar Nov 04 '15 20:11 frakman1