XLForm detects row value change

I am starting to use a very excellent XLForm project ( https://github.com/xmartlabs/XLForm ) for iOS, however I came across something that could possibly be answered very easily, but I cannot figure it out.

I want to detect a change in the value of a string - like a textbox or a segmented control. What method do I need to implement to catch this change? I'm guessing it comes from the controls themselves, but I'm not quite clear on how to do this since XLForm manages the controls.

Many thanks!

+3
ios xlform


source to share


4 answers


-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)formRow oldValue:(id)oldValue newValue:(id)newValue{

}

      



+4


source to share


As kindly pointed out on Github, here's how to do it:



https://github.com/xmartlabs/XLForm#dynamic-forms---how-to-change-the-form-dynamically-at-runtime

+1


source to share


Don't forget to call

[super formRowDescriptorValueHasChanged:oldValue:newValue]

      

Here's an example from above

-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)formRow oldValue:(id)oldValue newValue:(id)newValue
{
    // super implementation MUST be called
    [super formRowDescriptorValueHasChanged:formRow oldValue:oldValue newValue:newValue];

    if ([formRow.tag isEqualToString:@"alert"]){
        if ([[oldValue valueData] isEqualToNumber:@(0)] == NO && [[newValue valueData] isEqualToNumber:@(0)]){
            [self.form removeFormRow:formRow];
        }
    }
}

      

+1


source to share


For Swift:

override func formRowDescriptorValueHasChanged(formRow: XLFormRowDescriptor!, oldValue: AnyObject!, newValue: AnyObject!) {

print("changed!")

}

      

0


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics